Title: RE: Memory leak in SVGGraphics2D?

Maybe get rid of Java/WebSphere and get back to die-hard c++?

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 19, 2003 10:42 AM
To: 'Batik Users'
Subject: Memory leak in SVGGraphics2D?


I am using SVGGraphics2D to write Swing JComponents to SVG but seem to
be encountering a memory leak under Websphere(3.5.4 running Java 1.2.2)
running on AIX.  My code is very similar to the SVGGraphics2D demo code.
This code gets called repeatedly and leaks about 2 MBs per run.  If I
comment out the SVG code(but still create my chart object) the leak goes
away.  Any ideas of what could be happening?  I dispose of the
SVGGraphics2D object but that didn't help.

---------------------------

Chart ch = getChart(); // Chart extends JComponent

// Get a DOMImplementation
DOMImplementation domImpl =
    GenericDOMImplementation.getDOMImplementation();

// Create an instance of org.w3c.dom.Document
Document document = domImpl.createDocument(null, "svg", null);

// Create an instance of the SVG Generator
SVGGraphics2D svgGenerator = new SVGGraphics2D(document);

// Turn off double-buffering, otherwise the SVG will be a bitmap
setAllDoubleBuffered(frame.getRootPane(), false);

ch.revalidate();
frame.getRootPane().invalidate();
frame.getRootPane().validate();
ch.paint(svgGenerator);
ch = null;


// Write the SVG to the output.
Writer out = null;
try {
    out = new OutputStreamWriter(str, "UTF-8");
    svgGenerator.stream(out, true);
} finally {
    if(out != null) {
        out.close();
        out = null;
    }
}

// Release the SVG object from memory
svgGenerator.dispose();
svgGenerator = null;
domImpl = null;
document = null;

------------------------------




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to