Clion clangd, how to limit memory usage
Asked Answered
G

1

7

clangd uses a lot of Memory (Up to 2.5Gig on my System). On my 8GIG System I frequently run into OOM situations.

Currently the only solution I have found is to kill clangd once it uses a lot of memory.

clangd has some commandline options that look like they may reduce memory usage. But I have not found a way how to configure them in CLion.

CLion doesn't like limiting its memory via ulimit, but maybe it could be possible to limit memory only for the clangd processes?

Gomar answered 21/4, 2020 at 14:48 Comment(0)
B
10

Default limit for clangd is 8GB, but you can easily customize it. CLion offers you a bunch of settings via "registry". Open Help | Find Action ... and find for Registry.... In the registry find clion.clangd.max.memory and reduce value to 1000. In this case CLion will automatically kill clangd process if it will eat more memory that you specified.

enter image description here

You also can add Clangd Memory Indicator widget to bottom bar. In the latest CLion version you need to right click on bottom bar and enabled it.

enter image description here

BTW, clangd works only with opened files. So as few files opened in editor as less memory clangd eats. If it's not your case better to submit ticket to CLion tracker, cause 2.5 GB is too much IMHO.

Beastly answered 22/4, 2020 at 5:23 Comment(2)
Thanks, is there a similar way to limit the memory usage of clang-tidy? I couldn't find one. I think clangd processes also the #include files. There is an 18MB Header file (generated code) that is causing the excessive memusage.Gomar
I think clangd processes also the #include files. - Yes, indeed. clang-tidy will used the same limit as clangd If you use built-in clang-tidy and Use clang-tidy via clangd is enabled in Preferences | Languages & Frameworks | C/C++ | ClangdBeastly

© 2022 - 2024 — McMap. All rights reserved.