[comp.windows.x] Server Does Not Free Widget Resources

tae@censun1.UUCP (TAE) (12/08/90)

Does anyone know how to get the server to release ALL resources associated
with a widget when the widget is destroyed?

We have an application which creates and destroys widgets frequently.
Some widgets are fairly simple, like Push Buttons, while others are
more complex, like Selection Lists. With each widget we carefully specify
a destroy procedure for freeing up resources allocated by the widget.  

What we find is that upon a widget's destruction, the X server seems to
fail to release some of the widget resources as evidenced by the fact
that the size of server grows with each widget's creation and fails to reduce
correspondingly in size with each widget's destruction. The amount
of server growth with each widget creation and consequent destruction is
on the order of between 5-10 KBytes.

We have seen this problem on a variety of servers:
	
	MIT X11R3
	MIT X11R4
	NCD X terminal servers

We have seen the problem with every widget set we have used:

	HP X Widgets
	Motif Widgets

Also we have tested out at least one other application which creates and
destroys widgets and have not seen the problem.

We don't want to wait around until the connection to the server is closed
to get these resources freed up. Any ideas on where we are going wrong?

Leif Neve
Century Computing, Inc.
lneve@cen.com
    or
ln@fox.gsfc.nasa.gov

kaleb@thyme.jpl.nasa.gov (Kaleb Keithley ) (12/08/90)

In article <593@censun1.UUCP> tae@censun1.UUCP (TAE) writes:
> [...]
>What we find is that upon a widget's destruction, the X server seems to
>fail to release some of the widget resources as evidenced by the fact
>that the size of server grows with each widget's creation and fails to reduce
>correspondingly in size with each widget's destruction. The amount

You will never see the server process size shrink or reduce.  That's
just how malloc/free work.

-- 
Kaleb Keithley                      Jet Propulsion Labs
kaleb@thyme.jpl.nasa.gov

You can please all of the people some of the time,

schoch@sheba.arc.nasa.gov (Steve Schoch) (12/08/90)

In article <1990Dec7.175818.12931@thyme.jpl.nasa.gov>, kaleb@thyme.jpl.nasa.gov (Kaleb Keithley	) writes:
|> You will never see the server process size shrink or reduce.  That's
|> just how malloc/free work.

That's what I would have said too, except that he said the problem happened
on NCD X Terminal servers also.  NCD terminals don't run Unix, or a multi-
user OS in general so I would think they would use a different implementation
of malloc/free (The UNIX version of free makes the memory available to
future calls to malloc() but does not give the memory back to the kernel.)

My question to tae@censun1.UUCP is:  "How do you know how much server memory
an NCD terminal is using?"

	Steve

kaleb@thyme.jpl.nasa.gov (Kaleb Keithley ) (12/08/90)

In article <1990Dec7.212838.28921@news.arc.nasa.gov> schoch@trident.arc.nasa.gov (Steve Schoch) writes:
>In article <1990Dec7.175818.12931@thyme.jpl.nasa.gov>, kaleb@thyme.jpl.nasa.gov (Kaleb Keithley	) writes:
>|> You will never see the server process size shrink or reduce.  That's
>|> just how malloc/free work.
>
>That's what I would have said too, except that he said the problem happened
>on NCD X Terminal servers also.  NCD terminals don't run Unix, or a multi-
>user OS in general so I would think they would use a different implementation
>of malloc/free (The UNIX version of free makes the memory available to
>future calls to malloc() but does not give the memory back to the kernel.)

I don't know about NCD, but I was told that the Tek X Terminals use XINU,
which I presume uses a similar memory allocation scheme.

-- 
Kaleb Keithley                      Jet Propulsion Labs
kaleb@thyme.jpl.nasa.gov

You can please all of the people some of the time,

jimf@SABER.COM (12/08/90)

|What we find is that upon a widget's destruction, the X server seems to
|fail to release some of the widget resources as evidenced by the fact
|that the size of server grows with each widget's creation and fails to reduce
|correspondingly in size with each widget's destruction. The amount
|of server growth with each widget creation and consequent destruction is
|on the order of between 5-10 KBytes.

Under many (if not most) implementations of UNIX, it is impossible to
`shrink' a process (ie negative sbrk).  Thus your X server can grow
but will never shrink if you use such an implementation.

You often get this behavior on many systems where it *is* possible to
shrink a process because of malloc fragmentation.

Most often you'll find that the resident set size (RSS) of your server
will diminish when the resources are freed (because the pages aren't
being referenced) even though the process size does not.

jim frost
saber software
jimf@saber.com

tae@censun1.UUCP (TAE) (12/11/90)

In article <1990Dec7.212838.28921@news.arc.nasa.gov>, schoch@sheba.arc.nasa.gov (Steve Schoch) writes:
> My question to tae@censun1.UUCP is:  "How do you know how much server memory
> an NCD terminal is using?"
> 

Use the Setup key on your NCD terminal to go into Setup mode, click on 
"Diagnostic Session" and note the "Memory Free" field. 

	Leif