saviopalmieri / ctypes-opencv

Automatically exported from code.google.com/p/ctypes-opencv
0 stars 0 forks source link

Memory growth with callbacks in highgui #10

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
The highgui wrappers for window mouse callbacks and trackbar position
callbacks grows an internal list forever, although OpenCV just replaces
callbacks with newer versions.  My test environment was calling
cvSetMouseCallback for each image displayed, and between a lot of windows
and many iterations, the process grew to several hundred MB over a day of
testing.  More recent testing to track this down with 2 windows processing
~20fps for a few hours grew the process about 100k.

Anyway, I switched the callback function dictionary cache to use a
dictionary to hold the mouse/trackbar callbacks so they could be replaced.
 A patch is attached based on trunk r179.

Note that I have made minimal use of trackbars myself, but had to tweak
that code too since they share the cache with the mouse callbacks.  The
demos all seem to run fine though.

Original issue reported on code.google.com by db3l....@gmail.com on 1 Jan 2009 at 7:42

Attachments:

GoogleCodeExporter commented 8 years ago
Oh, i see. It was my fault. I was thinking of keeping the callback functions 
alive,
and not of clearing them properly after use. :)

Sorry for any trouble caused. Patched. Thanks.

Original comment by pmtri80@gmail.com on 1 Jan 2009 at 7:52

GoogleCodeExporter commented 8 years ago
No worries - in the scheme of things it was pretty easy to identify and I was 
being a
bit extreme with the callbacks with all the debug windows and images.

BTW, great job on all the memory work in general - manually releasing objects 
may not
be too bad in final code, though I'd hardly turn down automatic management even 
then,
but the dynamic management has been especially liberating during my current
prototyping and testing.  And so far, no other problems.

Original comment by db3l....@gmail.com on 1 Jan 2009 at 8:32