Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > swing JNI how to free memory

Thread Tools

swing JNI how to free memory

Posts: n/a

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:


Runtime r = Runtime.getruntime();

long before = r.freeMemory();

s.icon = null;
s.lable = null;
s = null;

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"
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


Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Why not using javax.swing.event with swing? S.T Java 2 05-25-2007 12:10 AM
javax.swing.Popup, javax.swing.PopupFactory lizard Java 0 01-30-2006 09:34 PM
Swing Model Classes Updating Swing Components on a Thread Other Than AWT mkrause Java 0 05-06-2005 04:32 PM
Java 1.2 Swing vs. Java 1.5 Swing Big Daddy Java 2 04-16-2005 01:14 PM