Reduce the number of circular references #5994
Closed
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 should avoid high memory usage due to largish object not being deleted immediately by the reference counter.
This should help #5826. It's not perfect (for instance, the exact example from #5826 is not fixed) but it fix our use case and the following sample:
As the discussion on #5826 concluded, this PR does not fix a memory leak but a high memory usage due to object not being freed by the reference counter. This is a issue for us because our uWSGI process may consume up to 1 GB of memory and never return it to the OS (probably because of memory fragmentation after GC pass). Right after startup our uWSGI consumer ~100mb which means the overhead if around 900 mb.
What is probably the biggest reason why this impact us more than other site, it's because some of your view process rather largish (300 kb) JSON to dict to JSON. And this JSON is made of numerous objects which probably increase the memory fragmentation.