(follow-up on https://roc.zulipchat.com/#narrow/channel/306878-off-topic/topic/casual.20conversation/near/509760742)
@Anton Today I caught it on my system monitor - no CPU hogging, but maxed out my memory - Helix :lsp-stop
freed 10GB :yum:
Oh interesting, I'll see if I can reproduce
I'll move us to a debugging topic then
3 messages were moved here from #off topic > casual conversation by JanCVanB.
Yesterday I ran apt update
/upgrade
and updated Roc alpha3 from early March to late March
Yeah, I can reproduce it, single letter edits cause 20-40 MiB jumps that never get cleaned up.
:orange_heart:
#7727 I'll do some digging tomorrow
Thank you! It's not a blocker for me :)
:+1: still a serious issue though
I haven't gotten far yet, I'm struggling to get good traces (with mem allocation info). Currently I have:
@bytes[
78d56ecad650 __libc_malloc+0 (/usr/lib/x86_64-linux-gnu/libc.so.6)
5b99ddbd06f5 crossbeam_channel::channel::bounded::h00081419fd333688+245 (/home/username/gitrepos/roc3/roc/target/debug/roc_language_server)
5b99ddb519e5 roc_load_internal::file::load_single_threaded::h72d2df977ee96e5e+597 (/home/username/gitrepos/roc3/roc/target/debug/roc_language_server)
5b99ddb34ae7 roc_load::load_single_threaded::h91b57ea8a7617560+487 (/home/username/gitrepos/roc3/roc/target/debug/roc_language_server)
78d56ed29c3c __clone3+44 (/usr/lib/x86_64-linux-gnu/libc.so.6)
]: 8503296
I've been using bpftrace, do you have any recommendations @Brendan Hansknecht?
Anton said:
Yeah, I can reproduce it, single letter edits cause 20-40 MiB jumps that never get cleaned up.
@Joshua Warner suggested earlier that he thinks the old parser likely has memory leaks. I would guess the s is what you are seeing. Though 40MiB sounds like a lot. We might just be keeping arenas alive and making new asts instead of dumping the old arena before making a new ast.
And no suggests past use valgrind if possible. With all its tracking flags, it can give a ton of info.
At least we won’t have to worry about that with the new parser!
valgrind --leak-check=full --track-origins=yes ...
is clean, so I'm going to check the arenas now.
heaptrack is a nice tool for this :)
When trying out some changes I've managed to make the problem worse (increased memory usage) :p this may help me find the cause though :fingers_crossed:
Heaptrack and Massif are both great (and in the new compiler Tracy)
I suspect the problem may come from crates/language_server/src/registry.rs:update_document
, that function has a lot of shady vibes :p in the sense that it may be keeping references alive too long. I'll give this one more day of investigating tomorrow.
When I keep repeating the same two edits (in the Roc code) the memory gains are very inconsistent, sometimes very small (as they should be), sometimes ~30 MiB. I can't explain that given everything I've learned about this issue, I'm calling it quits :white_flag:
I've also experienced this issue where the memory allocated by the lsp slowly grows and I have to kill and restart it. Happens over a period of 30 or so minutes
Last updated: Jul 06 2025 at 12:14 UTC