Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Excessive memory usage with clangd 19 #712

Open
TobiasBohnen opened this issue Nov 1, 2024 · 4 comments
Open

Excessive memory usage with clangd 19 #712

TobiasBohnen opened this issue Nov 1, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@TobiasBohnen
Copy link

Clangd-19's memory usage is at about 1GB on startup and steadily grows with each file opened, eventually reaching 8GB before crashing.
In my tests, version 18.1.8 peaks around 1GB, and typically idles at about 500MB.

Logs
clangdlog.txt

System information
clangd version: 19.1.3
clangd extension version: 0.1.29
Operating system: Windows 10

@TobiasBohnen TobiasBohnen added the bug Something isn't working label Nov 1, 2024
@HighCommander4
Copy link
Contributor

Are you able to share a code example on which a difference in memory usage can be observed?

@TobiasBohnen
Copy link
Author

I get this behavior even with a nearly empty project, although to a lesser extent:
https://github.com/TobiasBohnen/test

v19: ~150MB on startup, increases by ~1MB if I close and reopen 'main.cpp'
v18: ~13MB on startup, increases by ~100KB

@Lev275568
Copy link

Lev275568 commented Jan 7, 2025

I have same for:

  • clangd version 19.1.5
  • Ubuntu 24.04.1 LTS
  • llvm-vs-code-extensions.vscode-clangd 0.1.33

clangd command line parameter "--malloc-trim" helps to drop from 8000MB to 1600MB after changing file in IDE and after 1 minute.

@Lev275568
Copy link

Lev275568 commented Jan 9, 2025

In my case, switching to tcmalloc for clangd decreased memory consumption about 30%
sudo apt install google-perftools for tcmalloc
LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libtcmalloc.so.4 clangd

Also I've found that clangd creates additional thread for each opened vscode tab and this thread does not honor "-j" command line parameter. So, if there are a lot of tabs, and some common header file is changed, then clangd consumes a lot of memory (because is not honor?).

Related clice-project/clice#5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants