How to debug long-lived D program memory usage?

Adam D. Ruppe destructionator at gmail.com
Fri Apr 19 03:27:04 UTC 2019


On Friday, 19 April 2019 at 02:58:34 UTC, Alex wrote:
> Curious, what are these programs?

A terminal emulator gui (like xterm), a detachable terminal 
emulator (like gnu screen), a slack client, an irc client, and a 
bunch of http servers including d doc search, a work program, and 
a personal utility.

All of them would show growing memory time, some worse than 
others. You can see a lot of difference in them - gui programs, 
terminal programs, network server programs. But, I did write it 
all myself, so it could be a mistake I keep on making.

So far, I basically tracked down the terminal emulator things to 
being inefficient scrollback storage. I made the structs smaller 
and limited the amount saved more than before and cut this by 
half. The ddoc search was keeping the index in memory, that's 
fixed, but it still shows growing usage over time. Of course, 
restarting that is trivial if need be, but still, I wanna make 
sure I am doing it right too - especially if it is one of my 
underlying libraries to blame.

> You might have hook in to the GC and just write out stats, I 
> believe there is a stats collector somewhere though.

Yes, indeed. I am starting to make serious progress now - mostly 
the fault is me storing excessive histories inefficiently. Should 
have been obvious in retrospect, but I didn't realize just how 
much overhead there was in my designs!


More information about the Digitalmars-d-learn mailing list