Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

GC of Objects within a JFrame  RSS feed

dave taubler
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!