Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clion clangd, how to limit memory usage

Tags:

clion

clangd

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?

like image 603
arved Avatar asked Apr 21 '20 14:04

arved


1 Answers

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.

like image 143
Maxim Banaev Avatar answered Oct 30 '22 12:10

Maxim Banaev