🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.lang.java.programmer
4 messages
4 total messages Started by rocha Fri, 26 May 2000 00:00
How to force swing window to destroy
#581
Author: rocha
Date: Fri, 26 May 2000 00:00
8 lines
1132 bytes
I have an application which instantiates many different windows.  as the
application progresses, the performance degrades.  I have traces this
problem to the fact that none of the windows are being destroyed until
the application terminates and they are holding a lot of memory.  it
seems to me that something is still holding a reference to the windows(
possible the parent window), but i  don't know how to force there
destruction.  does anyone know how to do this?  thanks in advance
Ilougino Rocha.
Re: How to force swing window to destroy
#582
Author: Rijk van Haaften
Date: Fri, 26 May 2000 00:00
32 lines
2148 bytes
On Fri, 26 May 2000 10:17:30 +0100, rocha <rocha@haisystems.com>
wrote:

. I have an application which instantiates many different windows.  as the
. application progresses, the performance degrades.  I have traces this
. problem to the fact that none of the windows are being destroyed until
. the application terminates and they are holding a lot of memory.  it
. seems to me that something is still holding a reference to the windows(
. possible the parent window), but i  don't know how to force there
. destruction.  does anyone know how to do this?  thanks in advance
. Ilougino Rocha.

Parts (not all!) of the work can be done with dispose:

java.awt.Window.dispose()

dispose

public void dispose()

     Releases all of the native screen resources used by this Window,
     its subcomponents, and all of its owned children. That is, the
     resources for these Components will be destroyed, any memory they
     consume will be returned to the OS, and they will be
     marked as undisplayable. 

     The Window and its subcomponents can be made displayable again by
     rebuilding the native resources with a subsequent call
     to pack or show. The states of the recreated Window and its
     subcomponents will be identical to the states of these objects at
     the point where the Window was disposed (not accounting for
     additional modifcations between those actions). 
Re: How to force swing window to destroy
#583
Author: rocha
Date: Fri, 26 May 2000 00:00
41 lines
2595 bytes
I see that there is a way to get a window/frame's owned windows, but there is
no way to remove a window from that list.  if that is the case, that implies
that through out the life of a swing application, every window ever
instantiated will never be freed( which of course makes no sense to me ).  I
would imagine that there is a way to release a window from it's owner.  I just
don't know how

Rijk van Haaften wrote:

> On Fri, 26 May 2000 10:17:30 +0100, rocha <rocha@haisystems.com>
> wrote:
>
> . I have an application which instantiates many different windows.  as the
> . application progresses, the performance degrades.  I have traces this
> . problem to the fact that none of the windows are being destroyed until
> . the application terminates and they are holding a lot of memory.  it
> . seems to me that something is still holding a reference to the windows(
> . possible the parent window), but i  don't know how to force there
> . destruction.  does anyone know how to do this?  thanks in advance
> . Ilougino Rocha.
>
> Parts (not all!) of the work can be done with dispose:
>
> java.awt.Window.dispose()
>
> dispose
>
> public void dispose()
>
>      Releases all of the native screen resources used by this Window,
>      its subcomponents, and all of its owned children. That is, the
>      resources for these Components will be destroyed, any memory they
>      consume will be returned to the OS, and they will be
>      marked as undisplayable.
>
>      The Window and its subcomponents can be made displayable again by
>      rebuilding the native resources with a subsequent call
>      to pack or show. The states of the recreated Window and its
>      subcomponents will be identical to the states of these objects at
>      the point where the Window was disposed (not accounting for
>      additional modifcations between those actions).
Re: How to force swing window to destroy
#584
Author: Gregor Schmid
Date: Mon, 29 May 2000 00:00
33 lines
2036 bytes
Swing Components have quite a few invisible references to each other,
some of them in static caches, which makes it very difficult to really
isolate a window and all its nested components so the garbage
collector can do its job. Menus are especially troublesome.

What I do is walk the Component tree and break all parent/child
references, remove all menu items etc. This reclaims more than 90% of
the resources that are otherwise wasted.

You can find some example code in our free Java Library qflib which is
available at
http://www.qfs.de/en/projects/qflib/index.html

Take a look at de.qfs.lib.gui.SwingUtil.cleanup.

Regards,
	Greg

rocha <rocha@haisystems.com> writes:

> I have an application which instantiates many different windows.  as the
> application progresses, the performance degrades.  I have traces this
> problem to the fact that none of the windows are being destroyed until
> the application terminates and they are holding a lot of memory.  it
> seems to me that something is still holding a reference to the windows(
> possible the parent window), but i  don't know how to force there
> destruction.  does anyone know how to do this?  thanks in advance
> Ilougino Rocha.

-- 
Gregor Schmid                                      gs@qfs.de
Quality First Software                     http://www.qfs.de
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads