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

Introduce Storage::forget() to fix memory leak in Matrix::generic_resize() #1379

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

nickmertin
Copy link

Fixes #1378

Adds a trait method Storage::forget() to clean up the storage while forgetting (i.e., not dropping) the contents. Makes use of this method instead of mem::forget() in the implementations of Reallocator for DefaultAllocator.

@Andlon
Copy link
Sponsor Collaborator

Andlon commented Apr 10, 2024

Thanks, this is great! I don't have the head space or time to wrap my head around the nuances of the Reallocator API here at the moment, but I wanted to ask if the documentation needs to be updated to reflect any possible changes in assumptions made. I don't fully understand them yet myself, I'd need a closer look later to try to verify.

@nickmertin
Copy link
Author

Thanks! I looked over the documentation and I don't think any changes are necessary, as it maintains the assumption that the elements of the matrix are not dropped. My only question would be whether it would make more sense to move the new method to RawStorage instead of Storage.

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 this pull request may close these issues.

Memory leak in generic_resize/reallocate_copy
2 participants