My custom JPanel is retaining a large number of int arrays, as seen below in YourKit:
(source: gyazo.com )
I assumed this was the result of Graphic objects being undisposed of, but even with disposing every graphics object I use, the memory issues still occur.
The garbage collector will remove the objects if I force a heap dump (and the arrays are marked as unreachable). The behaviour causes Java to reach a high memory allocation (~700MB) however.
Are there any other common sources of this sort of issue in swing/JPanels?
Instead of a custom JPanel
, consider using JTable
, which uses the flyweight pattern to render only visible cells. Moreover, a suitable TableModel
may allow you to minimize the memory required for data storage. Finally, JTable
supports sorting and filteri ng in a way that may make large datasets more manageable by the user.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.