[comp.windows.x.motif] Memory Problem with List Widget

argv@turnpike.Eng.Sun.COM (Dan Heller) (10/08/90)

In article <9833@jpl-devvax.JPL.NASA.GOV> daniel@devvax.JPL.NASA.GOV (Daniel Hurley) writes:
> I am trying to create a list with a fixed size by deleting an item from the
> bottom of the list and then adding an item to the top of the list.
You really mean that you are trying to "maintain the size of the list"
by deleting and adding items.  right?

> My problem is that the program continues to grow in size.
The _program_ or the list?  I assume the program...

>           XtSetArg(args[arg], XmNitemCount, &count); arg++;
>           XtSetArg(args[arg], XmNitems, &items); arg++;
>           XtGetValues(list, args, arg);
> 
>           XmListDeleteItem(list, items[count-1]);
>           XmStringFree(items[count-1]);

The list retrieved by GetValues is always _read only_.  You are doing
very bad things by freeing this stuff.  If you called
    XmListDeleteItem(list, items[count-1]);
then you have done all that you are required to do.  Attempting to do
more (despite the fact there are bugs) is highly inadvisable.

> Does anyone have insight into how to keep the list widget from growing?
There are so many memory leaks in 1.0 (which is, I assume, what you're
using) it's hard to establish exactly which leak it is you're talking
about.  There are leaks in the list widget and in the XmString* functions,
so it's hard to determine which is responsible (maybe both).

--
dan
----------------------------------------------------
O'Reilly && Associates   argv@sun.com / argv@ora.com
Opinions expressed reflect those of the author only.