aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes GC of Objects within a JFrame Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "GC of Objects within a JFrame" Watch "GC of Objects within a JFrame" New topic
Author

GC of Objects within a JFrame

dave taubler
Ranch Hand

Joined: May 15, 2001
Posts: 132
Hi,
I did a search for this topic, and didn't find much that was posted yet. My question concerns memory leaks resulting from creating a Frame or JFrame that is filled with GUI Components, and then closing the Frame without explicitly nulling those Components out. Do memory leaks happen that way? Or is Java and the GC saavy enough to not let this happen.
The gist of it is, let's say I have a JFrame that remains open throughout the life of the application. (Call it masterFrame). Within masterFrame, there is a JButton that, when clicked, causes an instance of SubFrame to be instantiated and made visible. SubFrame has 3 JButtons, a JTextArea, and 5 JLabels. Now, let's say the user closes subFrame. By the time this is finished happening, I haved nulled out JFrame's reference to subFrame (and there are no other references to subFrame). At this point, are the JButtons, JTextArea and JLabels elligible for garbage collection as well? Or do all of their references need to be explicitly nulled out as well?
Thanks in advance!


Dave Taubler<br />Specializing in <a href="http://taubler.com/articles/" target="_blank" rel="nofollow">Java and Web Development</a>
 
 
subject: GC of Objects within a JFrame