Hi everyone,
A few days ago, I noticed that I'm probably breaking some sort of record,
because ctwm has been running on my workstation at work for over 150 days
straight. But one thing worried me: the ctwm process was taking about 10
megabytes of memory, compared to just 3 MB or so that a "fresh" ctwm process
takes. Growth of about one megabyte a month (!) doesn't indicate a huge
memory leak, but it can point to a memory leak nonthless.
So my first question is: has anyone ever undertaken an effort to check
whether ctwm has any memory leaks, and if there are, hunt them down?
But even before anyone answers, I decided to try it myself. I took the
official ctwm 3.7 release's code, threw in my own leak-detection code (which
I can publish if anyone is interested), and started running this instrumented
version of ctwm on my home machine and looking for leaks. I've only started
this process, but I believe I already found several leaks.
I ran the following silly loop
for i in `seq 200`
do
xterm -geometry +0+0 -n $i -e "sleep 3"& usleep 500000
done
Which basically opens 200 xterm windows, one after the other, where around
6 windows are open at any given time. After this loop finishes, nothing
should have been added to ctwm's memory use - all windows have been closed,
all icons freed, and so on. Unfortunately, it doesn't appear to be the case,
and I found two leaks at least: (note that I've taken a very strict definion
of a leak - I always try a repeated operation, and call something a leak only
if repeated allocations are left behind).
The first leak appears to be icon names which are allocated (when fetched
from the WM property) but never freed. The call trace of this allocation
is:
GetWMPropertyString /tmp/ctwm-3.7/util.c:3919
AddWindow /tmp/ctwm-3.7/add_window.c:1098
HandleMapRequest /tmp/ctwm-3.7/events.c:2372
DispatchEvent /tmp/ctwm-3.7/events.c:503
HandleEvents /tmp/ctwm-3.7/events.c:547
main /tmp/ctwm-3.7/ctwm.c:959
A second, more significant leak, is title highlight images which are
allocated but never freed. The call trace of this allocation is:
CreateHighlightWindows /tmp/ctwm-3.7/add_window.c:1718
CreateWindowTitlebarButtons /tmp/ctwm-3.7/add_window.c:2005
AddWindow /tmp/ctwm-3.7/add_window.c:1282
HandleMapRequest /tmp/ctwm-3.7/events.c:2372
DispatchEvent /tmp/ctwm-3.7/events.c:503
HandleEvents /tmp/ctwm-3.7/events.c:547
main /tmp/ctwm-3.7/ctwm.c:959
These are just two example leaks I found - I can quite easily point to more.
The question is - is anyone interested that I continue to point to more
leaks as I find them? Can someone look into the code that I accuse to be
leaky, and check whether indeed it is such, and if so, how it can be fixed?
I would have loved to do this part myself too, but unfortunately I'm too
busy and too ignorant of ctwm's code inner-working to do this effectively.
Thanks,
Nadav.
--
Nadav Har'El | Monday, Sep 26 2005, 23 Elul 5765
[EMAIL PROTECTED] |-----------------------------------------
Phone +972-523-790466, ICQ 13349191 |Share your knowledge. It's a way to
http://nadav.harel.org.il |achieve immortality.