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

fix memory leak from constructor exceptions #653

Merged

Conversation

peterhillman
Copy link
Contributor

Addresses #256 and #258, based on fix suggested in #256
Signed-off-by: Peter Hillman peterh@wetafx.co.nz

Signed-off-by: Peter Hillman <peterh@wetafx.co.nz>
Copy link
Contributor

@meshula meshula left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks to be a lot more robust. The repetition of the clean up block is worrying - the worry is that in the future if someone touches code near one of the clean up blocks, and also makes a change in that nearby clean up block, they might not consistently apply a necessary fix in all the repetitive instances. Would it make sense to have a private clean up method, that also assigns nullptr to _data after the delete, in order that we are future-proofed against this possibility?

@cary-ilm cary-ilm added the Needs Discussion To be discussed in the technical steering committee label Feb 5, 2020
@peterhillman
Copy link
Contributor Author

@meshula, how about this approach? Nesting the try/catch blocks rather than having the same cleanup code in two alternate catch blocks? It seems a little ... unorthodox ... and we still have two similar code blocks in the two separate constructors. They aren't quite identical though, and I'm not sure if those differences are necessary.

@meshula
Copy link
Contributor

meshula commented Feb 6, 2020

This version is easier to follow. The double nesting of try's feels a bit... pythonic, in the sense that some of our existing APIs are a little "leap before you look". I think the nesting as you have it is fine given the way the rest of the code works. A future pass could involve adding API to check if the resize within initialize() is possible, before actually going through the actual work, but I think it's more important to correct the leak before contemplating deeper changes.

@peterhillman peterhillman merged commit 51bd0ff into AcademySoftwareFoundation:master Feb 6, 2020
@peterhillman peterhillman deleted the memoryleaks branch February 6, 2020 23:00
@cary-ilm cary-ilm added this to the v2.5.0 milestone Apr 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Discussion To be discussed in the technical steering committee v2.5.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants