• Post Reply Bookmark Topic Watch Topic
  • New Topic

NT memory leak for jpg images?  RSS feed

swarraj kulkarni
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I am trying to load the jpg file for conversion to wbmp. It is done through a servlet running on Tomcat. The servlet code is as follows. the problem is if I test this simple code for say 50 users load, I can see that the virtual memory usage goes up. Also the memory usage of java.exe process goes up in short time. I am observing this on NT Taskbar. I am using jdk1.3 hotspot client.
The servlet code :-
import java.awt.*;
import java.awt.image.*;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.net.*;
import javax.swing.*;
import com.iproject.wbmpcreator.*;
public class GifTestServlet extends HttpServlet {

public void init(ServletConfig sc)
System.out.println("In the init of GifTestServlet");

public void doGet(HttpServletRequest request,HttpServletResponse response)
throws ServletException, IOException
URL url = new URL("http://localhost:8080/examples/Testfile.jpg");
Image image = Toolkit.getDefaultToolkit().createImage(readURL(url));
}catch(Exception e)
}while((image.getWidth(null)==-1) | | image.getHeight(null)== -1);

System.out.println("loaded image width= " + image.getWidth(null));
System.out.println("loaded image height= " + image.getHeight(null));

image =null;
}catch(Exception err){err.printStackTrace();}
public static final byte[] readURL(URL url)
throws MalformedURLException, IOException
BufferedInputStream bufferedinputstream = new BufferedInputStream(url.openStream());
ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream();
byte abyte0[] = new byte[2048];
int i;
while((i = bufferedinputstream.read(abyte0, 0, 2048)) != -1)
bytearrayoutputstream.write(abyte0, 0, i);

bufferedinputstream = null;
return bytearrayoutputstream.toByteArray();
If the mediatracker is used instead of the do-while loop, then the memory usage goes up fast :O(

[This message has been edited by swarraj kulkarni (edited June 12, 2001).]
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!