I have questions similar to yours. I want to share what I see with
"memprof" (I don't have Purify). It can track an application that
you run with it, and can produce a leak report after the application
exits.

E.g. I run memprof .lib/lt-test1 in test/Xm/pushbutton, use the window
border button to close the test (after which it remains visible but
inactive), and can then use the memprof UI to get the leak report.

The leak report I just produced for this particular test is attached
as an example. Maybe the combination of memprof and Purify can
teach us more.

        Danny

On Tue, 2004-11-09 at 18:07, Dave Williss wrote:
> I just updated my Lesstif source from CVS and found some changes to fix the 
> FontList leaks.  I hadn't seen any CVS commit messages for them, but the 
> fixes work and seem to fix MOST of the leaks.
> 
> It took me a while to see that it really was a fix because the old code was 
> doing something silly and the new code looked like it would leak even worse 
> at first glance.  Then I noticed the change to ResConvert.c which made it 
> make sense.  In the places where the font list is copied in initialize(), 
> I'd add a comment such as /"FontList specified is cached.  We need to copy 
> it now so we can free it later. */
> 
> There's another Font List problem in Label.c (and maybe LableG.c, I didn't 
> check it).  The very first thing Label.c's initialize does (line 604) is 
> check the FontList and if it's NULL or unitialized allocates one with 
> _XmGetDefaultFontList(). Then later (line 670) it does the same thing, but 
> uses the XmBUTTON_FONTLIST if the thing is not an xmLabelWidgetClass. 
> However, since it's already allocated it above, it will never get there and 
> instead, will COPY the font list it allocated at line 604, causing the 
> original to leak.  Granted, it's a rare case.  I thought I was hitting it 
> but apparently I'm not. It's just a potential leak.
> 
> I have one more FontList leak that I can't seem to track down. We have one 
> place where we call XmCreatePushButton as a child of the application's 
> toplevel widget, but never manage the button.  Instead, we use XtGetValues 
> to get the default values of the background and shadow colors, then just 
> destroy it with XtDestroyWidget.  The fontlist for this button--and only 
> this button--still leaks  It's a minor leak though compared to the others 
> which you did fix.
> 
> Here's the Purify trace...
> 
>     malloc         [dbgheap.c:138]
>     XtMalloc       [alloc.c:120]
>     XmFontListEntryLoad [fontlist.c:572]            <-- several small 
> allocations in this function.
>     _XmFontListResourceAddEntry [resconvert.c:1716]
>     XmCvtStringToXmFontList [resconvert.c:1863]
>     CallConverter  [convert.c:855]
>     XtConvert      [convert.c:946]
>     GetResources   [resources.c:845]
>     XtGetResources [resources.c:1053]
>     xtCreate       [create.c:377]
>     XtCreateWidget [create.c:557]
>     XtCreateWidget [create.c:585]
>     XmCreatePushButton [pushb.c:1541]
>     GetPixelValues [micon.c:171]        <-- our module, not part of Lesstif
> 
> It occurs to me though, that maybe this is just the first widget that needs 
> a FontList, so this is the place where the one instance gets allocated.  In 
> which case, maybe I'm just not calling something I should to clean up on 
> exit?

-- 
Danny Backx - danny.backx-at-planetinternet.be    http://up.to/danny.backx
Leaked 0x80766a8 (20 bytes)
        _XmRegionCreate(): ../../../SOURCE/lib/Xm-2.1/Region.c:123
        initialize(): ../../../SOURCE/lib/Xm-2.1/DropSMgr.c:386
        CallInitialize()
        xtCreate()
        _XtCreateWidget()
        XtCreateWidget()
        _XmGetDropSiteManagerObject(): ../../../SOURCE/lib/Xm-2.1/Display.c:560
        _XmDropSiteWrapperCandidate(): 
../../../SOURCE/lib/Xm-2.1/DropSMgr.c:2551
        ResizeWrapper(): ../../../SOURCE/lib/Xm-2.1/BaseClass.c:1274
        ResizeWrapper4(): ../../../SOURCE/lib/Xm-2.1/BaseClass.c:591
        initialize(): ../../../SOURCE/lib/Xm-2.1/Label.c:761
        CallInitialize()
        CallInitialize()
        xtCreate()
        _XtCreateWidget()
        _XtVaCreateWidget()
        XtVaCreateManagedWidget()
        main()
        [0x4036495d]
        _start(): ../sysdeps/i386/elf/start.S:105
Leaked 0x8076330 (8 bytes)
        _XmRegionCreate(): ../../../SOURCE/lib/Xm-2.1/Region.c:127
        initialize(): ../../../SOURCE/lib/Xm-2.1/DropSMgr.c:386
        CallInitialize()
        xtCreate()
        _XtCreateWidget()
        XtCreateWidget()
        _XmGetDropSiteManagerObject(): ../../../SOURCE/lib/Xm-2.1/Display.c:560
        _XmDropSiteWrapperCandidate(): 
../../../SOURCE/lib/Xm-2.1/DropSMgr.c:2551
        ResizeWrapper(): ../../../SOURCE/lib/Xm-2.1/BaseClass.c:1274
        ResizeWrapper4(): ../../../SOURCE/lib/Xm-2.1/BaseClass.c:591
        initialize(): ../../../SOURCE/lib/Xm-2.1/Label.c:761
        CallInitialize()
        CallInitialize()
        xtCreate()
        _XtCreateWidget()
        _XtVaCreateWidget()
        XtVaCreateManagedWidget()
        main()
        [0x4036495d]
        _start(): ../sysdeps/i386/elf/start.S:105
Leaked 0x80726b0 (40 bytes)
        _XmFontListEntryCreate(): ../../../SOURCE/lib/Xm-2.1/FontList.c:49
        __XmFontListAlloc(): ../../../SOURCE/lib/Xm-2.1/FontList.c:75
        XmFontListAppendEntry(): ../../../SOURCE/lib/Xm-2.1/FontList.c:185
        main()
        [0x4036495d]
        _start(): ../sysdeps/i386/elf/start.S:105
Leaked 0x80726a0 (8 bytes)
        XmFontListAppendEntry(): ../../../SOURCE/lib/Xm-2.1/FontList.c:185
        main()
        [0x4036495d]
        _start(): ../sysdeps/i386/elf/start.S:105
Leaked 0x8072690 (12 bytes)
        __XmFontListAlloc(): ../../../SOURCE/lib/Xm-2.1/FontList.c:65
        XmFontListAppendEntry(): ../../../SOURCE/lib/Xm-2.1/FontList.c:185
        main()
        [0x4036495d]
        _start(): ../sysdeps/i386/elf/start.S:105
Leaked 0x8072228 (40 bytes)
        _XmFontListEntryCreate(): ../../../SOURCE/lib/Xm-2.1/FontList.c:49
        XmFontListEntryCreate(): ../../../SOURCE/lib/Xm-2.1/FontList.c:382
        main()
        [0x4036495d]
        _start(): ../sysdeps/i386/elf/start.S:105
Leaked 0x806f678 (23 bytes)
        VirtKeysInitialize(): ../../../SOURCE/lib/Xm-2.1/VirtKeys.c:1140
        _XmVirtKeysInitialize(): ../../../SOURCE/lib/Xm-2.1/VirtKeys.c:1233
        initialize(): ../../../SOURCE/lib/Xm-2.1/Display.c:393
        CallInitialize()
        xtCreate()
        _XtAppCreateShell()
        XtAppCreateShell()
        GetXmDisplay(): ../../../SOURCE/lib/Xm-2.1/Display.c:521
        XmGetXmDisplay(): ../../../SOURCE/lib/Xm-2.1/Display.c:749
        secondary_object_create(): ../../../SOURCE/lib/Xm-2.1/Vendor.c:916
        initialize_prehook(): ../../../SOURCE/lib/Xm-2.1/Vendor.c:1008
        InitializeRootWrapper(): ../../../SOURCE/lib/Xm-2.1/BaseClass.c:1550
        CallInitialize()
        CallInitialize()
        CallInitialize()
        CallInitialize()
        CallInitialize()
        CallInitialize()
        CallInitialize()
        CallInitialize()
        CallInitialize()
        CallInitialize()
        xtCreate()
        _XtAppCreateShell()
        XtVaAppCreateShell()
        _XtVaOpenApplication()
        XtVaAppInitialize()
        main()
        [0x4036495d]
        _start(): ../sysdeps/i386/elf/start.S:105
Leaked 0x806a430 (28 bytes)
        class_initialize(): ../../../SOURCE/lib/Xm-2.1/Vendor.c:664
        XtInitializeWidgetClass()
        XtInitializeWidgetClass()
        XtInitializeWidgetClass()
        xtWidgetAlloc()
        xtCreate()
        _XtAppCreateShell()
        XtVaAppCreateShell()
        _XtVaOpenApplication()
        XtVaAppInitialize()
        main()
        [0x4036495d]
        _start(): ../sysdeps/i386/elf/start.S:105
Leaked 0x8052028 (8 bytes)
        XmFontListEntryCreate(): ../../../SOURCE/lib/Xm-2.1/FontList.c:384
        main()
        [0x4036495d]
        _start(): ../sysdeps/i386/elf/start.S:105

Reply via email to