Memory management #17
-
Hello, Thank you for creating this amazing library. I have a question about memory management. When using this library, do I need to release the data allocated by OpenCV? Coming from Python, I don't have much knowledge about C++ and internal Dart FFI. From what I understand, in C++, you need to manually release the memory allocated by OpenCV. https://www.opencvhelp.org/tutorials/best-practices/memory-management-opencv/ Since this library calls OpenCV via FFI, OpenCV will definitely allocate some memory. I'm not sure if Dart garbage collector knows to release the memory? Or if you have added the code to handle that automatically? I saw that there is no Personally I haven't observed or checked for memory leak, but I want to ask just to be sure. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Yes, memory management is very important when interacting to native codes, but thanks to dart team, they provided ffi.Finalizable interface to attach a native resource to a dart class, so when the attached dart class is freed by GC, the native resources will also be freed, so generally you needn't to worry about it, but when I tested in pure dart, it seems GC won't triggered correctly and memory increased constantly, but in flutter GC was triggered and worked fine. Also, I admit that there must be some incorrectly management on native resources, if you occured a memory leak, please open an issue. I recommed you use the new comming v1.0.0 version, now it is not published and you can find more in |
Beta Was this translation helpful? Give feedback.
Yes, memory management is very important when interacting to native codes, but thanks to dart team, they provided ffi.Finalizable interface to attach a native resource to a dart class, so when the attached dart class is freed by GC, the native resources will also be freed, so generally you needn't to worry about it, but when I tested in pure dart, it seems GC won't triggered correctly and memory increased constantly, but in flutter GC was triggered and worked fine. Also, I admit that there must be some incorrectly management on native resources, if you occured a memory leak, please open an issue.
I recommed you use the new comming v1.0.0 version, now it is not published and you can find m…