feat: allow freeing of ustring table for debugging cases#5193
Open
lgritz wants to merge 2 commits into
Open
Conversation
Contributor
|
Thanks for the quick turnaround! But the allocations for entries and pool in |
This patch optionally frees the contents of the ustring table as the
process is exiting. It's triggered one of two ways:
- `OIIO::attribute("ustring:cleanup", 1);`
- Environment variable `OIIO_USTRING_CLEANUP=1`
If neither is used, the teardown won't happen, thus avoiding any
pointless work when it should be exiting the process.
The purpose of this is that when using certain debugging tools, the
ustring table (which only grows and never frees) looks like a memory
leak, even though it's by design. Someimes, it's useful to make it not
appear ot leak, and you are happy for a large table to spend time
pointlessly freeing all the data.
Fixes 3913
Assisted-by: Claude Code / Sonnet 4.6
Signed-off-by: Larry Gritz <lg@larrygritz.com>
c131c43 to
fbeaff2
Compare
* Coalesce repeated pool block allocation logic into allocate_pool_block(). * Change all_pools and large_allocs to vectors of std::unique_ptr so clearing the vec frees the pointers automatically. * shrink_to_fit() after clearing all_pools and large_allocs. * Initialize all TableRepMap fields by default, especially the pointers. * When in debug mode, print when freeing the ustring table resources, so we are sure it happens. Signed-off-by: Larry Gritz <lg@larrygritz.com>
Collaborator
Author
|
I updated with some tightening up of the allocation logic, including shrink_to_fit on the vectors. Also, I added a print message when it does the free (for Debug builds only, and only if you have turned on the ustring cleanup), maybe you can verify that it's really running the cleanup. If it's printing that and still complaining about leaks, is it able to tell you which allocation it is that's still never freed? |
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.
This patch optionally frees the contents of the ustring table as the process is exiting. It's triggered one of two ways:
OIIO::attribute("ustring:cleanup", 1);OIIO_USTRING_CLEANUP=1If neither is used, the teardown won't happen, thus avoiding any pointless work when it should be exiting the process.
The purpose of this is that when using certain debugging tools, the ustring table (which only grows and never frees) looks like a memory leak, even though it's by design. Someimes, it's useful to make it not appear ot leak, and you are happy for a large table to spend time pointlessly freeing all the data.
Fixes #3913
Assisted-by: Claude Code / Sonnet 4.6