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

Explicitly del model in ModelLibrary.map_function #173

Closed
braingram opened this issue Jul 24, 2024 · 0 comments · Fixed by #181
Closed

Explicitly del model in ModelLibrary.map_function #173

braingram opened this issue Jul 24, 2024 · 0 comments · Fixed by #181

Comments

@braingram
Copy link
Collaborator

In the following loop:

for index, model in enumerate(self):
try:
yield function(model, index)
finally:
# this is in a finally to allow cleanup if the generator is
# deleted after it finishes (when it's not fully consumed)
self.shelve(model, index, modify)

The lack of an explicit del model after the shelve keeps it in scope until it's overwritten by the enumerate iterator which only overwrites it after the next model is loaded. This results in 2 models in memory when only 1 is needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant