Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   swing JNI how to free memory (http://www.velocityreviews.com/forums/t390656-swing-jni-how-to-free-memory.html)

John_Woo 02-06-2007 05:11 PM

swing JNI how to free memory
 
Hi,

I had a class Screen extends JWindow, and this class had a few
attributes as

ImageIcon icon = new ImageIcon("big jpg");

JLabel lable.setIcon(icon);

then in main class, after creating Screen s, did the following:

System.gc();

Runtime r = Runtime.getruntime();

long before = r.freeMemory();

s.icon = null;
s.lable = null;
s.dispose();
s = null;
System.gc();

long after = r.freeMemory();

from (after-before), I saw free memory increased a lots, but from some
trace tool, I saw that the reference still there, like

Paths from "GC Roots" to "Object ToolkitImage #004fdf56"
sun.awt.image.ToolkitImage
image of javax.swing.ImageIcon
defaultIcon of javax.swing.JLabel
[0] of java.awt.Component[3]
component of javax.swing.JPanel
contentPane of javax.swing.JRootPane
rootPane of Screen [JNI Global]

consulting the tool vendor, it said the object is referenced by native
called, can't really free up by setting null

I'm wondering, how to clean up such object or free swing component?


--
Thanks lots

John
Toronto



All times are GMT. The time now is 04:23 AM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.