I tried another scenario to find leaks. This time, I created many iconic
windows, in hope of (not) finding leaks in icon handling. The loop I ran
was:

        for i in `seq 500`
        do
        xterm -iconic -geometry +0+0 -n $i -e "sleep 3"& usleep 500000
        done

Unfortunately, I found four new possible leaks:

12 bytes per iconic winow are leaked in CreateIconWindow() in a line that
does
    if (icon->match != match_none)
         AddToList (&tmp_win->iconslist, icon->pattern, (char*) icon);

perhaps nobody frees this iconslist from tmpwin when the window closes?
The full stack trace of this allocation:

        AddToList       /home/nyh/tmp/ctwm-3.7-patched/list.c:117
        CreateIconWindow        /home/nyh/tmp/ctwm-3.7-patched/icons.c:757
        Iconify /home/nyh/tmp/ctwm-3.7-patched/menus.c:3988
        HandleMapRequest        /home/nyh/tmp/ctwm-3.7-patched/events.c:2451
        DispatchEvent   /home/nyh/tmp/ctwm-3.7-patched/events.c:503
        HandleEvents    /home/nyh/tmp/ctwm-3.7-patched/events.c:547
        main    /home/nyh/tmp/ctwm-3.7-patched/ctwm.c:959


Now we arrive at three leaks that might be related, and might be some sort
of attempt to do image caching, and not exactly a leak. However, if this is
an attempt to do caching, I don't understand it, because what remains
allocated are just small, administrative structures, and not the actual
icon image - of which there is just one (all icons had the same image -
my default xterm XPM; note that the icons had different textual labels,
though).

The first image-cache-related leak is 12 bytes per iconic window, with the
following stack trace:

        AddToList       /home/nyh/tmp/ctwm-3.7-patched/list.c:117
        GetImage        /home/nyh/tmp/ctwm-3.7-patched/util.c:3156
        CreateIconWindow        /home/nyh/tmp/ctwm-3.7-patched/icons.c:512
        Iconify /home/nyh/tmp/ctwm-3.7-patched/menus.c:3988
        HandleMapRequest        /home/nyh/tmp/ctwm-3.7-patched/events.c:2451
        DispatchEvent   /home/nyh/tmp/ctwm-3.7-patched/events.c:503
        HandleEvents    /home/nyh/tmp/ctwm-3.7-patched/events.c:547
        main    /home/nyh/tmp/ctwm-3.7-patched/ctwm.c:959

A second image-cache-related leak of 20 bytes per iconic window, is
in LoadXpmImage() at image = (Image*) malloc (sizeof (struct _Image))
full stack trace:


        LoadXpmImage    /home/nyh/tmp/ctwm-3.7-patched/util.c:751
        GetXpmImage     /home/nyh/tmp/ctwm-3.7-patched/util.c:796
        GetImage        /home/nyh/tmp/ctwm-3.7-patched/util.c:3160
        CreateIconWindow        /home/nyh/tmp/ctwm-3.7-patched/icons.c:512
        Iconify /home/nyh/tmp/ctwm-3.7-patched/menus.c:3988
        HandleMapRequest        /home/nyh/tmp/ctwm-3.7-patched/events.c:2451
        DispatchEvent   /home/nyh/tmp/ctwm-3.7-patched/events.c:503
        HandleEvents    /home/nyh/tmp/ctwm-3.7-patched/events.c:547
        main    /home/nyh/tmp/ctwm-3.7-patched/ctwm.c:959

And a third, larger leak of 80 bytes per iconic window comes from a Icon
structure created in CreateIconWindow() but never freed:

        CreateIconWindow        /home/nyh/tmp/ctwm-3.7-patched/icons.c:464
        Iconify /home/nyh/tmp/ctwm-3.7-patched/menus.c:3988
        HandleMapRequest        /home/nyh/tmp/ctwm-3.7-patched/events.c:2451
        DispatchEvent   /home/nyh/tmp/ctwm-3.7-patched/events.c:503
        HandleEvents    /home/nyh/tmp/ctwm-3.7-patched/events.c:547
        main    /home/nyh/tmp/ctwm-3.7-patched/ctwm.c:959


And that's it, for now. I hope this helps.


-- 
Nadav Har'El                        |       Tuesday, Sep 27 2005, 24 Elul 5765
[EMAIL PROTECTED]             |-----------------------------------------
Phone +972-523-790466, ICQ 13349191 |Sorry, but my karma just ran over your
http://nadav.harel.org.il           |dogma.

Reply via email to