Memory leak and poor performance i PyROOT when adding arrays to vector

It is described in this topic:

and there was a ticket for it. If you want I can try to find it. Basically, initialising or += of a numpy >=2D array to a vector crashed. Seems to be fixed now, at least for 2D numpy arrays. Haven’t tried for 3D yet.

I understand, that the garbage collector in Python cleans up object to which there are (nearly) no references. Here, clearly, there is a memory leak, so something is not cleaned by garbage collector, and I have a feeling that the contents of the array.array are copied inside the vector, but somehow the array.array object is being held after this copying, not derefrenced.

This is also described in the post I quote at the beginning. Basically, std vector was not accepting numpy arrays with types such as uint32. It was crashing. It was, however, accepting array.array types. Thus in this line I use array.array to convert numpy array to something acceptable by ROOT std vector, as a workaround. In this example I’ve given a double which I think worked OK, but in my code I deal with unsigned ints or unsigned shorts, which were crashing. Perhaps this conversion is working well now (I need to check), but it was not at the moment of writing the post that I refer to. Anyway, thanks to this workaround, I discovered the reported memory leak and slowdown.