You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Similar to #13 I do not believe that this is an actual memory leak, but rather an observation of how Pythons garbage collector works. Please also see my response there.
Currently convert_pixel_format allocates a new frame buffer for the result of the frame conversion and returns this in the form of a new Frame object. That means every time the function is called, new memory is allocated. The mentioned example will simply take the result of this transformation and display it. After displaying the result, the Frame that holds the conversion result is discarded.
This discarded Frame instance (and its corresponding frame buffer) are now no longer referenced and will be freed (at some point) by the garbage collector. But the Python garbage collector has some leeway in when the actual freeing should take place.
Here I have a screenshot of an execution of asynchronous_grab_opencv.py running on my machine.
As you can see the memory consumption does increase quite a bit as more and more frames are converted and the frame buffer for these results accumulate. But after some time the garbage collector jumps in and removes these unreferenced buffers. Over time the maximum consumption grows (default behaviour of the Python garbage collector) but at some point it settles and jumps in more or less at consistent times/memory usage.
If you want to have more control over how garbage collection takes place, take a look at the built-in gc module of Python. It allows you to configure how garbage collection takes place. With gc.collect you can even force garbage collection at specific moments.
As mentioned in #13 these limitations are more or less to be expected of Python as garbage collected language. If you need predictable memory consumption I would recommend looking at our VmbC or VmbCPP APIs where memory management is a more manual task. This provides better control over when and where memory is allocated and freed.
Issue
There seems to be a memory leak in frame.py#convert_pixel_format
How to reproduce
Run example asynchronous_grab_opencv.py with camera module 1800 U-2050m. Every received frame increases memory consumption.
Additional information
Memory leak occurs in function convert_pixel_format. Removing the convertion in the sample code eliminates the memory leak.
VmbPy/Examples/asynchronous_grab_opencv.py
Line 170 in 48ad455
The text was updated successfully, but these errors were encountered: