fix: memory not released after indexing (20GB+ RSS for 5MB data)#833
Open
fxfxfx123 wants to merge 3 commits into
Open
fix: memory not released after indexing (20GB+ RSS for 5MB data)#833fxfxfx123 wants to merge 3 commits into
fxfxfx123 wants to merge 3 commits into
Conversation
- Set mi_option_arena_purge_mult=1 (default 10) so arenas are purged aggressively without extra delay - Set mi_option_page_reclaim_on_free=1 to reclaim pages from exited worker thread heaps - Lower DEFAULT_RAM_FRACTION from 0.5 to 0.25 to reduce memory budget Signed-off-by: fxfxfx123 <93531292+fxfxfx123@users.noreply.github.com>
Memory scales linearly with worker count (each gets its own mimalloc arena + 8MB stack). Diminishing returns past 8 workers. On a 20-core CPU this reduces peak memory by up to 60% with negligible speed loss. Signed-off-by: fxfxfx123 <93531292+fxfxfx123@users.noreply.github.com>
Move inline trailing comments to preceding lines to match project style and satisfy clang-format-20. Signed-off-by: fxfxfx123 <93531292+fxfxfx123@users.noreply.github.com>
Owner
|
Thanks for the Windows memory-retention fix for #832. Triage: high-priority stability/performance PR. Review will check the mimalloc options and worker-count change separately: we need post-index RSS to return to sane levels, but we also need to avoid an over-broad throughput regression or conflicting with the explicit memory-budget work in #752/#685. Please keep the before/after memory evidence current in the PR. |
Author
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
After indexing a small project (65 files, 1.3MB, 2509 nodes), codebase-memory-mcp retains 20GB+ RSS on a 32GB Windows machine. Memory grows monotonically and is never released to the OS.
Root Cause (from source code)
Fix
Benchmark
Tested on Windows 11, i7-12700, 32GB RAM, 65-file project.