Closed jim-easterbrook closed 5 years ago
I think I've worked out what's happening. Whenever it receives a CameraWidget
object (e.g. from gp_widget_get_child
) the Python interface calls gp_widget_ref
on its root object, to ensure the widget tree doesn't get deleted while the Python object exists. When the Python object is deleted the interface calls gp_widget_unref
on the root object.
The problem is with gp_camera_get_config
which returns the root object. This newly allocated object already has a ref count of 1, so calling gp_widget_ref
increases it to 2. When the Python object is deleted it returns the count to 1 and the C object is not freed.
OK, I think commit b8966a5 should cure this. @AntiSol - do you need a new release immediately? (I've got no other changes planned, so there's no great reason not to, but I don't like to do new releases too often.)
If you'd prefer I'm happy to give it a try without a release, that'll let me confirm that it's fixed, as long as I'm not going to have too much trouble with the "Install from GitHub" instructions from the readme - will that overwrite the version installed by pip? or should I remove the pip version first?
Ah, I've just remembered that's a bit of a hassle. You'd need to install SWIG. I'll do a release.
ok. thanks :)
Now released as v1.8.5.
and confirmed fixed. My hero! Thanks so much!
Thank you for finding and reporting the bug.
This simple script consumes ever larger amounts of memory.
I've established that removing the
gp_widget_ref
call in the Python interface gets rid of the leak, but leaves the Python interface vulnerable to the C object getting deleted prematurely.