[clangd] Trim memory periodically when using glibc malloc
This diff addresses the issue of the ever increasing memory usage of clangd. The key to understand what happens is to use `malloc_stats()`: malloc arenas keep getting bigger, although the actual memory used does not. It seems some operations while bulding the indices (both dynamic and background) create this problem. Specifically, 'FileSymbols::update' and 'FileSymbols::buildIndex' seem especially affected. This diff adds a call to `malloc_trim()` periodically in ClangdLSPServer. Fixes: https://github.com/clangd/clangd/issues/251 Fixes: https://github.com/clangd/clangd/issues/115 Reviewed By: sammccall Differential Revision: https://reviews.llvm.org/D93452
Loading
Please sign in to comment