xavierd / clang_complete

Vim plugin that use clang for completing C/C++ code.
http://www.vim.org/scripts/script.php?script_id=3302
1.95k stars 308 forks source link

Excessive memory usage with libclang #142

Open ghost opened 12 years ago

ghost commented 12 years ago

Opening many C++ files at once results in quite some CPU burn and excessive memory use of about 30MB per buffer. Nothing really big is included, except the STL, and most files open share a large set of includes. Still, every additional buffer uses about 30MB of memory.

xavierd commented 12 years ago

30MB is not much, try to include boost and you can easily have a buffer of 500MB :). But yeah maybe we should do something smart to "reclaim" memory from unused buffer.

ghost commented 12 years ago

I know, boost is really evil in this regard. As much as I like clang_complete, using this much memory, and not sharing it between buffers on top of that, is just insane. Reclaim could help, but a global symbol cache for all open buffers (if that's possible) would be much more useful.

oblitum commented 12 years ago

HEY!, I've 16GB, that's why I was not seeing that! This is a little weird.... I mean, at last, memory should be reclaimed. I've opened up a file with boost headers and it popped up 150~200 MB. But even if I wipeout all opened buffers, memory don't go down only up... I expect it do not take too long in a programming session without the need close everything and opening again. This is serious issue.

nmelchior commented 11 years ago

I see there hasn't been any activity on this issue, but I'd like to note that this is still an issue for me in recent git (350bebc). I work on a large codebase that uses boost, and I need to restart my editor frequently (something I would never ordinarily do). ATM, I have 40 buffers open and gvim is using 18.8 GiB of virtual memory, 11 GiB resident. AFAIK, clang_complete still doesn't release memory when a buffer is deleted, so I will have to restart soon.

oblitum commented 11 years ago

@nmelchior I've provided a good enough fix at #187 but that pull is from months ago and was already dropped. It worked well for me when I used clang_complete. Since then I've switched to YCM, I've not checked whether it's an issue there or just not a issue at all upfront.

oblitum commented 11 years ago

For reference, this was the commit: https://github.com/oblitum/clang_complete/commit/a40db517bfa40760f1cbe92c6bf216e3da62ed4d

nmelchior commented 11 years ago

@oblitum Thanks for the tip. YCM was easy to install, blazing fast, and very easy on the RAM.