【发布时间】:2014-11-28 13:49:22
【问题描述】:
我有一些 JPanel 连接到 JTabbedPane。 每个 JPanel 都包含存储在 JTable 中的大量数据。
在 JTabbedPane 中显示 Tabs 后,加载数据,分配给程序的内存从 16Mb 跳转到 60Mb。
当关闭任何选项卡时(通过jTabbedPane.removeTabAt(selectedIdx)),我注意到分配的内存没有减少。
我做了一个“分析”和“堆内存转储”。结果是:JTable 数据还在内存中。
- 为什么
jTabbedPane.removeTabAt(selectedIdx)不释放添加到 JTabbedPane 对象的面板中创建的所有对象? - 如何解决?
【问题讨论】:
-
1.
The result is: the JTable data is still in memory.== 这是正确的结果,2What may be the problem here?== 一切都是关于Each JPanel contains large data stored in JTable.3.What may be the problem here?== 取决于您对 JTabbedPane 中每个 Tab 的期望 -
我希望从选项卡中显示许多面板。在每个面板的 initComponents() 方法中,加载了一些数据。我希望在删除标签时释放内存。
标签: java swing memory-leaks jtable jpanel