Skip to content
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

Fixed setup() memory leak #1782

Merged
merged 7 commits into from Nov 24, 2020
Merged

Fixed setup() memory leak #1782

merged 7 commits into from Nov 24, 2020

Conversation

tadkollar
Copy link
Member

Summary

There were a couple of things causing the memory leak in Group._get_scope(). The big one was that _scope_cache was using refs to subsystem instances as dict keys. So when they were dereferenced elsewhere during setup(), the _scope_cache dict still held refs to the old objects because there's no automatic way to clear it out.

Initially, I addressed this by using the id() of the subsystem objects as dict keys, but there was still a small leak. This was because following a setup(), the subsystem instances were different even if the info in _scope_cache was the same. I ended up using the subsystem pathname as the key, and testing on cache hits to make sure it still referred to the same object.

I added a test that runs setup() 10 times and then 100 times and checks for differences in memory usage afterwards. If the difference is more than 10k, it fails.

Related Issues

@project-bot project-bot bot added this to In progress in OpenMDAO Dev [Read only] Nov 24, 2020
OpenMDAO Dev [Read only] automation moved this from In progress to Reviewer approved Nov 24, 2020
@swryan swryan merged commit 7517ec5 into OpenMDAO:master Nov 24, 2020
OpenMDAO Dev [Read only] automation moved this from Reviewer approved to Done Nov 24, 2020
@tadkollar tadkollar deleted the memleak1746 branch December 1, 2020 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Possible memory leak in compute totals
4 participants