-
-
Notifications
You must be signed in to change notification settings - Fork 485
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_elements() to fix memory leak in Matrix::generic_resize() #1379
Conversation
Thanks, this is great! I don't have the head space or time to wrap my head around the nuances of the |
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 |
I haven't forgotten this PR, but I haven't yet been able to devote time to it. It came up on Discord though, and @sebcrozet suggested that the I'll try to get back to this soon, but I suspect I'll be quite busy this week. |
I like the name I don't think it should be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks appropriate to me! And I agree, I think a name like forget_elements
would be great to help highlight that it's the elements that are being forgotten and not the storage itself (which will be dropped normally absent any other intervention.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're absolutely right about the fact that forget
doesn't have to be unsafe
@nickmertin! I just have a few minor suggestions, then we can get this merged in time for the next release :)
Sounds good, I will make the necessary changes this weekend. |
I believe it is now good to go, let me know if any other changes are needed! |
Thanks @nickmertin, it's ready to merge now. Great to have this bug fixed! I'm not merging immediately because of the breaking change in introducing |
Hey! Thank you for this PR @nickmertin, and @Andlon and @tpdickso for reviews. |
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 ofmem::forget()
in the implementations ofReallocator
forDefaultAllocator
.