Fix memory not being freed after point cloud decimation#342
Merged
JanuszBedkowski merged 1 commit intoMapsHD:mainfrom Feb 7, 2026
Merged
Conversation
Member
|
wow , Yau are amaizing! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
When decimating point clouds, the
decimate()function creates new smaller vectors and assigns them to the member vectors. However,std::vectorassignment does not reduce capacity - it keeps the original memory allocation even when the new data is much smaller.This meant that even with aggressive decimation, the application retained the full memory footprint of the original undecimated point clouds.
Solution
Added
shrink_to_fit()calls after each vector assignment inPointCloud::decimate()to release unused memory back to the system.Results
Tested on
multi_view_tls_registration_step_2.exewith a 5km dataset using 0.2m decimation. Before the fix, the application used 80GB of RAM. After the fix, it uses only 10GB - an 88% reduction in memory usage. (Tested on Windows with msvc compiler)Files changed
core/src/point_cloud.cpp- Addedshrink_to_fit()to 6 vectors indecimate()