-
-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory leak in interface getters #198
Comments
Yeah, that totally needs fixing. Thanks for the heads-up. |
I think that ffi needs to have any type of smart pointer because it's a nightmare to have to deal with freeing them at this point. Something realated to finalizers maybe? I don't know if you have any solution for this or any workaround to avoid memory leaks before posting the issue in dart ffi. Another issue that maybe could need to be addressed here is auto releasing interfaces (implemented in IUnknown) before garbage collection, maybe using finalizers too. I've tried to understand how they works but cannot find any working example. |
We do have some samples of resource management here: This introduces the concept of a |
I've been looking at the code trying to implement some interfaces.
I've noted that at the end of getters there is a
free
statement to release memory allocated earlier, but if the native function does not succeed an exception is thrown and the memory is not freed.Let's take for example a code snipped taken from IFileOpenPicker.dart, you'll see what I mean:
Because the pointer is generated inside the function it must be freed even if another type of exception is thrown (ie, calling
.fromAddress
,.asFunction
, etc.)The text was updated successfully, but these errors were encountered: