Java – why does my jdialogs leak?

I have a JFrame from which I open a jdialog and another jdialog – menas from the dialog. I have three windows visible (JFrame, jdialog1, jdialog2)

When I close both dialog boxes and run the garbage collector several times (from NetBeans Profiler), I can see that jdialog2 (the one opened from jdialog1) is garbage collection, but jdialog1 (opened from JFrame) is still hung in the active object pool

Every time I create a new object - so after a while I have an outofmemoryerror Doue to a memory leak

Do I have to deal with jdialogs in a special way to avoid leakage?

By the way, I do setdefaultcloseoperation (jdialog. Dispose_on_close) on two dialog boxes,

Solution

To release the allocated resources, you must call the dispose method It is not enough to just hide the dialog box

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>