-
-
Notifications
You must be signed in to change notification settings - Fork 25
isolates memory not being auto freed #97
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
Comments
Well, it seems the free of smart pointer is wrong, I will fix it soon. |
@abdelaziz-mahdy Please update to v1.0.9 and test whether it is better, leave more messages if the problem still exists. |
thank you very much, i can no longer see a memory leak, even without forcing the dispose, so auto dispose is working i think having async support built in will be awesome but i dont know if native threads or isolates is better |
Yes, but it's not easy, there are much works todo, for dart isolates, the most difficult one is that native resources can't be passed, BUT as you mentioned, they are trying to implement As for native ways, we need to refactor all APIs to add callbacks, it's crazy and I do not want to refactor them again... So maybe with "sendable native resources" supported it will be easier, but I do not think it's easy to implement, because native resources created in main isolate will needs to be copied to helper isolate. If you have better solutions please tell me or try to implement it, I do think we should support async so I have added it to TODO in readme, but it just not easy... |
I think we can take https://pub.dev/packages/image as a reference since he used a different approach, if that doesn't work for our case then I guess people will need to implement their own background handlers same as I did then Also if you want to add my app to your readme as examples I don't mind, |
You mean the commands? Yes it's another way to implement async, but adding every API to command is laborious and not efficient because many memory copies will be needed, maybe with GAPI implemented this way will be the best option for now.
Thanks~ It will be helpful for other developers. I will update the readme to link to your repo.
I remember that opencv 4.9.0 just support a few TFLite operators, I tried many tflite models but opencv can't even load them, that's why I removed TFLite, but in opencv 4.10.0 it seems the support of TFLite is much better, so you can try it now, thanks for your efforts in advance~ |
For async tasks, if I found an easy workaround will let you know My point of trying tflite to make use of apple chip GPU, since from what I am seeing the detection of faces is slow so it may not being fully utilizing GPU power, detection of 60 images using 5 isolates finishes in 10 sec so I don't think it's using gpu |
Maybe you can try to use OPENCL, although it's also slow on my AMD chip and shows some warnings, but it does use GPU, maybe some extra configurations needed. final faceDetector = cv.FaceDetectorYN.fromBuffer(
"onnx",
buf,
Uint8List(0),
(320, 320),
backendId: cv.DNN_BACKEND_OPENCV,
targetId: cv.DNN_TARGET_OPENCL,
); |
@abdelaziz-mahdy maybe we should close this issue now? |
Describe the bug
when running opencv tasks inside isolates example https://github.com/abdelaziz-mahdy/face_grouping/blob/ac18fed722f7ec773632acc7ca613c91ff4afb08/lib/image_service.dart the memory will not be auto freed by finalizer i think this issue is related
dart-lang/sdk#55062
#64 (comment) is the same problem
i think for my case i will need to dispose before finishing the tasks inside isolate , so i will keep this for tracking
edit: even force dispose doesnt free memory abdelaziz-mahdy/face_grouping@0e75777 i dont think there is any missing dispose
actions to redo the memory leak, proccesss dir multiple times
The text was updated successfully, but these errors were encountered: