1

I'm doing some profiling on a legacy Java product and hunting down memory leaks using YourKit. I'm plugging quite a lot - but I keep coming across an issue that I just cannot solve.

I have quite a few windows/dialogs that when I close them (and call dispose in the case where they derive from JDialog) they just aren't being GC'd. YourKit reports that the only root to the GC is "target of sun.awt.windows.WDialogPeer [JNI Global]". There are some weak references too which seem to mostly come from MetalToolBarUI. Presubably these only exist because of this one strong reference from WDialogPeer.

Has anyone seen this before - or can anyone give me an idea how and or/why WDialogPeer is holding onto my JDialogs/JFrames? How can I clean it up?

Jumwah
  • 517
  • 5
  • 19
  • Is [this](http://stackoverflow.com/q/6309407/261156) the same? – Catalina Island Jul 27 '12 at 14:04
  • have you `dispose()`ed the child panel and frames? – Steven Fines Jul 28 '12 at 19:04
  • Yes, dispose is called (and all call super) everywhere - I've double checked this. Still reading the other post - thanks :) – Jumwah Jul 30 '12 at 08:56
  • Thanks for responses... I've tracked it down. There was a JDialog being held as a member variable initialized in a constructor. Although this was being disposed correctly - the deriving class was ALSO setting this member variable by newing it - so it was constructing two JDialogs, but only ever disposing one. – Jumwah Jul 30 '12 at 09:32

0 Answers0