Fix memory leak in ImageDisplay.cc #287
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Note: This is a big memory leak in the order of 30 MB/s or more depending on many conditions; thus it should be prioritized. A 32GB RAM machine can run out of memory after approximately 20 min of real time simulation.
I don't like the interface of common::Image outputting a raw pointer that is deleted if the input is non-nullptr but it is up to the caller to the delete if it's not called again. And it's not documented either.
I don't like the amount of unnecessary copies required by
ImageDisplay::ProcessImage
either. Or the fact that we do one allocation per frame (instead of trying to keep an allocated region while in use).But all those are problems for another day.
Don't forget to merge this to ign-gui5 and later :)
🦟 Bug fix
Fixes gazebosim/gz-sim#1011
Checklist
codecheck
passed (See contributing)Note to maintainers: Remember to use Squash-Merge