Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #597

Re: Memory Leak in swing

From "cakmak" <cakmak@THRWHITE.remove-dii-this>
Subject Re: Memory Leak in swing
Message-ID <1168269379.411367.169040@q40g2000cwq.googlegroups.com> (permalink)
Newsgroups comp.lang.java.gui
References <1168248935.342086.314340@s34g2000cwa.googlegroups.com><
Date 2011-04-27 15:28 +0000
Organization TDS.net

Show all headers | View raw


  To: comp.lang.java.gui
The leak is still there. What I made is :

1.) Read the binary stream from the db :

rs=stmt.executeQuery(query);
if(rs.next()){
    int len=rs.getInt(2);
    byte [] b=new byte[len];
    InputStream in = rs.getBinaryStream(3);
    try {
            in.read(b);
            in.close();
            img=Toolkit.getDefaultToolkit().createImage(b);
     } catch (IOException e) {
            e.printStackTrace();
    }
}
stmt.close();
rs.close();


2.) store the image as field :
this.icon =  new ImageIcon(img);

3.) After a while I remove the object from my collection and on the
overridden method finalize() I also call the flush() method.

if(this.icon != null){
            this.icon.getImage().flush();
            this.icon = null;
}


The surviving objects still increase?!  On the page of SUN they
submitted a bug. But this is set on closed/fixed.
(http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4014323) What am I
doing wrong? I also use the byte[] constructor on creating the icon and
my java version is 1.5.0_10.

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

Back to comp.lang.java.gui | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Memory Leak in swing appl "cakmak" <cakmak@THRWHITE.remove-dii-this> - 2011-04-27 15:28 +0000
  Re: Memory Leak in swing "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:28 +0000
    Re: Memory Leak in swing "cakmak" <cakmak@THRWHITE.remove-dii-this> - 2011-04-27 15:28 +0000
      Re: Memory Leak in swing "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:28 +0000
  Re: Memory Leak in swing "cakmak" <cakmak@THRWHITE.remove-dii-this> - 2011-04-27 15:28 +0000
    Re: Memory Leak in swing "cakmak" <cakmak@THRWHITE.remove-dii-this> - 2011-04-27 15:28 +0000
      Re: Memory Leak in swing "steve" <steve@THRWHITE.remove-dii-this> - 2011-04-27 15:28 +0000
        Re: Memory Leak in swing "cakmak" <cakmak@THRWHITE.remove-dii-this> - 2011-04-27 15:28 +0000
          Re: Memory Leak in swing "steve" <steve@THRWHITE.remove-dii-this> - 2011-04-27 15:28 +0000
      Re: Memory Leak in swing "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:28 +0000
      Re: Memory Leak in swing "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:28 +0000

csiph-web