-
Notifications
You must be signed in to change notification settings - Fork 95
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 not being released #30
Comments
It's useful to run this using a debug build, which shows that there is a leak, and that the allocation was made here: https://github.com/php-ds/extension/blob/master/src/ds/ds_set.c#L12 ds_set_t *set = ecalloc(1, sizeof(ds_set_t)); We're obviously not freeing sets properly, and we should also check for memory leaks in CI. I'll open an issue to discuss to best way to do that. |
Fixed in e937fb5 |
That's good to know. I might try setting one up on my end to test things.
It appears that as soon as a union, intersection, xor, etc… are performed memory will still be leaked. While C is not my strong suit I know my way around some of it. I might try my hand at and fixing some of these issues. I'm sure PRs fixing (or — attempting to) could be helpful? |
Your detective work has been incredibly helpful to the point where I get excited when I see you've created a new issue or PR. PR's fixing would definitely be helpful though, would be cool to have someone else dig into the C as well. It's very satisfying to fix these.
How can you tell? 🤔 |
I boiled it down to a test case:
Output:
Aside: I've got another issue where php-ds freezes related to sets containing Hashable objects containing sets containing Hashable objects (… and then turtles?). I'll open another issue with the details. |
Debug build output for a single loop shows:
Which collapses down to:
|
It appears that allocated space is not being freed resulting in large memory usage. I believe entire object graphs are staying around when stored in sets.
I've tested these classes that all seem to have the problem:
Notes: Neither calling
clear()
on the set nor the use ofgc_collect_cycles()
frees any memory.Example reproduction:
Output:
Environment:
Edit: 10x iteration count + output changes to showcase larger memory footprint
The text was updated successfully, but these errors were encountered: