Article View: borland.public.jbuilder.java.swing
Article #11216Re: JDialog, JTable, and Garbage Collection
From: Max Polk
Date: Mon, 28 Jun 1999 00:00
Date: Mon, 28 Jun 1999 00:00
24 lines
1769 bytes
1769 bytes
In article <37739F78.D5314A78@jhmi.edu>, lelliot@jhmi.edu says... > I have an application in which the action of a JButton is to show a > JDialog that contains a JTable on a JScrollPane. I am using > Intuitive's OptimizeIt to watch for objects that are not being garbage > collected. > When the JDialog is disposed, the JDialog, JScrollPane and JTable are > not garbage collected. It appears as though they are the owners of the > focus. Is it possible for a dialog to be diposed and still own the > focus? Is there a way to tranfer the focus back to the main frame of > the application once the Jdialog has been disposed ? Please realize that if you have a custom cell renderer, there is a horrible memory leak in Swing if you return a new object for each cell. Instead, you *MUST* return the same component for each cell. For example, the default cell renderer extends JLabel and returns this for each row and cell requested. It simply sets the text to be a different thing, sets the color if highlighted etc, then returns "this". If you have multiple types of components displayed, return the same object for each type. We ran into this and the memory leak crashed the JVM in a matter of hours of usage. It doesn't say this in the API, only in the Java Tutorial.
Technical Details
Message-ID:
<MPG.11e1f952e9c4d8eb9896ff@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<37739F78.D5314A78@jhmi.edu>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,da7978491cba0025 X-Google-Attributes: gid111d45,public From: none@none.invalid (Max Polk) Subject: Re: JDialog, JTable, and Garbage Collection Date: 1999/06/28 Message-ID: <MPG.11e1f952e9c4d8eb9896ff@forums.borland.com> X-Deja-AN: 495013788 References: <37739F78.D5314A78@jhmi.edu> Organization: Another Netscape Collabra Server User Newsgroups: borland.public.jbuilder.java.swing