Skip to content

Memory consumption #64

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

Closed
abdelaziz-mahdy opened this issue May 28, 2024 · 7 comments · Fixed by #67
Closed

Memory consumption #64

abdelaziz-mahdy opened this issue May 28, 2024 · 7 comments · Fixed by #67
Labels
bug Something isn't working

Comments

@abdelaziz-mahdy
Copy link
Contributor

Describe the bug
memory is not being freed correctly i think
this is my example https://github.com/abdelaziz-mahdy/face_grouping

try to pick a dir with images in it it should extract the faces in it,

from the devtools the memory should be 100mb
image

but in activity monitor its 2 gb
image

Expected behavior
i think the memory should be the same as devtools and since they are not the same i think there is a problem with how the c part frees the memory

Desktop (please complete the following information):

  • OS: Macbook pro m2

Smartphone (please complete the following information):

  • Device: Macos
  • ABI Version arm64

Additional context
Add any other context about the problem here.

@abdelaziz-mahdy abdelaziz-mahdy added the bug Something isn't working label May 28, 2024
@rainyl
Copy link
Owner

rainyl commented May 28, 2024

I have tested your example, yes, on windows a memory leak also observed.

It seems native resources are not correctly freed in cv.imread and cv.imencode, could you please replace the dependency of opencv_dart with issue-64 branch in your pubspec.yaml and test it? I tested on windows and it seems ok.

@abdelaziz-mahdy
Copy link
Contributor Author

I will try to test at night, thank you for your help ❤️

@rainyl
Copy link
Owner

rainyl commented May 28, 2024

It seems an increase of ~20M still exists every time opening a directory, but much better now, and the reason may be an abuse of arena, but I am not clear why...

Anyway, I will reassess all arena recently.

@abdelaziz-mahdy
Copy link
Contributor Author

i can confirm its much better now
image
its lower in devtools, dont know if ffi objects are not kept in the tracking or something
image

@rainyl
Copy link
Owner

rainyl commented May 29, 2024

Just for remind myself,

According to dart-lang/sdk#54233 , dart objects are small but native objects are large, so GC will not execute as we expected to free native resources timely, but I am still confusing why arena will not release memory automactically...

Releated:

@rainyl rainyl linked a pull request May 30, 2024 that will close this issue
3 tasks
@abdelaziz-mahdy
Copy link
Contributor Author

abdelaziz-mahdy commented Jun 12, 2024

image

in some cases i still face the same problem, yes it got reduced alot but still happens, do you know how can i identify objects in memory so i can dispose what is not disposed, or we can check it to check why GC doesnt clean it

btw i opened devtools and forced GC but it didnt delete the objects

@rainyl
Copy link
Owner

rainyl commented Jun 13, 2024

Yes, the memory increases constantly even when I switch around different tabs... will keep tracking

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants