W3C home > Mailing lists > Public > www-jigsaw@w3.org > November to December 2003

RE: servlet and memory leakage

From: Laird, Brian <BLaird@perseco.com>
Date: Mon, 1 Dec 2003 09:28:12 -0600
Message-ID: <45A6279F82E4CA4BBDC0F4EFC7B6A2FE127F36@atlas.perseco.com>
To: "Red K" <redkresearch@yahoo.com.sg>, <www-jigsaw@w3.org>

Here are few of my comments / questions on this:

1) What version of the JDK are you using?
2) Can you upgrade to 2.2.3?
3) You need to be sure to do some clean up of all the IO classes.
Example, I didn't see a close or destroy for the BufferedImage or the
ImageWriter class.
4) You may need to start the JVM with more aggressive memory management.
Things like minimum & maximum heap size as well as the garbage
collection method.  

Hope this helps,

-----Original Message-----
From: Red K [mailto:redkresearch@yahoo.com.sg] 
Sent: Friday, November 28, 2003 2:28 AM
To: www-jigsaw@w3.org
Subject: servlet and memory leakage

Hi, dear all:

I wrote one servlet on Jigsaw 2.0.5. This servlet
draws one graph in memory and writes it the HTTP
response as an jpeg image.
I notice that every request to the servlet will cause
some amount of memory leakage in my Jigsaw server. And
if I request it at a higher rate, the Jigsaw server
will prompt it runs out of memory.
I just learn to use Java. However, I know that Java
claims automatic memory leakage prevension.
So I am puzzled. Is this problem caused by my poor
Java programming or by Jigsaw possible bugs?
The servlet is as the following:
import java.io.*;
import java.util.*; 
import javax.servlet.ServletException; 
import java.io.*;
import java.util.*;
import javax.imageio.*;
import java.awt.image.*;
import java.awt.*;
import javax.imageio.stream.*;
import javax.servlet.ServletOutputStream; 
import javax.servlet.http.*;

public class StockImgServlet extends HttpServlet
        int[] A = new int[100];
        public void oneRead(String stock, int ratio)
throws IOException
                //1. read in price list
                BufferedReader in = new
BufferedReader(new FileReader(stock));
                int i;
                        String line = in.readLine();
                        Integer value = new
                        A[i] = value.intValue();
        public void doGet(HttpServletRequest req,
HttpServletResponse res)
        throws IOException, ServletException
                //1. get stock and ratio values
                String stock =
                String ratio_string =
                Integer ratio_obj = new
                int ratio = ratio_obj.intValue();
                //2. set content type
                //3. check stock
                //4. generate img and dump out
                BufferedImage img = new
                Graphics2D g = img.createGraphics();
                int i;
                        Iterator w =
                        ImageWriter writer =
                        ImageOutputStream ios =
                catch(Exception e)

Do You Yahoo!?
Faster. Easier. Search Contest. 

This e-mail and any accompanying documents or files contain information that is the 
property of Perseco, that is intended solely for those to whom this e-mail is addressed 
(i.e., those identified in the "To" and "Cc" boxes), and that is confidential, proprietary, 
and/or privileged.  If you are not an intended recipient of this e-mail, you are hereby 
notified that any viewing, use, disclosure, forwarding, copying, or distribution of any of 
this information is strictly prohibited and may be subject to legal sanctions.  If you have 
received this e-mail in error, please notify the sender immediately of any unintended 
recipients, and delete the e-mail, all attachments, and all copies of both from your system.

While we have taken reasonable precautions to ensure that any attachments to this e-mail 
have been swept for viruses, we cannot accept liability for any damage sustained as a 
result of software viruses.
Received on Monday, 1 December 2003 10:26:08 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:25:38 UTC