swing JNI how to free memory

Discussion in 'Java' started by John_Woo, Feb 6, 2007.

  1. John_Woo

    John_Woo Guest

    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
     
    John_Woo, Feb 6, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Big Daddy

    Java 1.2 Swing vs. Java 1.5 Swing

    Big Daddy, Apr 15, 2005, in forum: Java
    Replies:
    2
    Views:
    501
    Pete Barrett
    Apr 16, 2005
  2. mkrause
    Replies:
    0
    Views:
    674
    mkrause
    May 6, 2005
  3. Panduranga Chary

    How memory function free() knows how much memory to free.

    Panduranga Chary, Dec 27, 2007, in forum: C Programming
    Replies:
    2
    Views:
    418
    Keith Thompson
    Dec 27, 2007
  4. george
    Replies:
    0
    Views:
    1,146
    george
    Aug 29, 2008
  5. mohammed_a_o
    Replies:
    0
    Views:
    287
    mohammed_a_o
    Nov 30, 2010
Loading...

Share This Page