libheif icon indicating copy to clipboard operation
libheif copied to clipboard

Unregister default plugins on deinitialization

Open stepkamipt opened this issue 3 years ago • 2 comments

Unregister default plugins to prevent memory leaks in plugin's objects, for example, ctxIdxLookup in libde265

stepkamipt avatar Jul 26 '22 08:07 stepkamipt

I'm wondering when the destructor will ever be called since this is a static, global singleton variable.

farindk avatar Jul 27 '22 17:07 farindk

@farindk yes, you're right, thank you. So, I created another PR with API methods to deinitialize plugins manually: https://github.com/strukturag/libheif/pull/656

And I found that there are couple of issues related to problem I'm facing: https://github.com/strukturag/libheif/issues/531 and https://github.com/strukturag/libheif/issues/535

stepkamipt avatar Aug 01 '22 10:08 stepkamipt

Thank you. I have merged this, but changed the usage. Instead of calling heif_unregister_*(), it is now good practice to initialize and cleanup with heif_init() and heif_deinit(). These are reference counted, heif_deinit() will then effectively call heif_unregister_*(). Please try in the master branch and let me know if you see any issues with this.

farindk avatar Aug 30 '22 17:08 farindk

@farindk thank you! I've try the master branch and everything works perfect.

stepkamipt avatar Sep 16 '22 11:09 stepkamipt