你可以用另一个主线程控制这个FRAME的生命期。

解决方案 »

  1.   

    正如楼上说的,这样在Thread在interrupt()以后就会自动的gc,不过这样可能会牺牲一点效率,因为每次Thread的start和JFram/JDialog的初始化都会牺牲一些时间(不过个人觉得java的图形初始化时间本来就比较慢)。看你系统的要求了。
      

  2.   

    需要立刻回收内存的话用System.gc()吧。
      

  3.   

    我测试了一下,在反复打开/关闭窗口时,java占用的内存一直在上涨,没有看到内存释放的情况,只有当我将整个系统关闭的时候,系统才将内存释放出来了。
      

  4.   

    java 中对dispose()方法的解释:
    Releases all of the native screen resources used by this Window, its subcomponents, and all of its owned children. That is, the resources for these Components will be destroyed, any memory they consume will be returned to the OS, and they will be ed as undisplayable.