• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JDialog not disposing child JDialog

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have one JDialog that creates a new local variable of type JDialog. I do a .show() on the child to show it and do a setVisible(false) on the parent to hide it.
Inside the child on an action performed I do a dispose(). But the finalize is not actually executed until the parent is finalized. This is a problem because I want to cache the first dialog and re-use if for the life of the app.
Ideas?
 
Ranch Hand
Posts: 286
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does your parent dialog (or any other objects) have a handle to this child that might be keeping it from GCing?
If you are worried about the memory space it takes, why are you keeping the parent dialog around either?
If you need something to happen that you set up in a custom finalize(), why not just move it to a different method you call instead of dispose() that will then do your special thing and then call dispose() itself.
Just some questions that might help clarify your needs...
HTH
 
Cy Bird
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The only reason I was looking into reusing the parent was for performance reasons. However, it seems to be a domino effect... the parent isn't releasing the child, and the child isn't releasing the grandchildren. How can I troubleshoot what might be holding a reference? Any pointers?
Thanks.
 
Chris Shepherd
Ranch Hand
Posts: 286
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
is your parent dialog a very complex/expensive one to create? Does it get called alot?
As to watching handles, you really just have to check your code and make sure all references to the child is released. As a dialog tho, I wouldn't expect handles to be spread around very much. dialogs usually are one off items that don't need to be *handled* except when called because they are recreated when you need them. Do you use a global variable to when you create the child? Can you show me a bit of code on how you call the child? It might help. If you use a global/object variable when you create the child instead of a local(only valid inside that method) one, then that would possibly explain whats happening. Show me some code and maybe I can help more.
 
Cy Bird
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
- It is fairly expensive (4 JTables and a bunch of JCheckboxes). It is called very often.
- I found out what method is causing things to not release (when I comment out it's released after 2 gc). Now just need to figure out why. We're doing some static calls, so I think that might be a player.
Thanks for the help.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic