The OutOfMemory exception is thrown by the system thread.You can override
the 'sun.awt.exception.handler' property to specify your own Outofmemory
error handler.

System.setProperty("sun.awt.exception.handler",
"com.acme.OutOfMemoryErrorHandler");


Your handler would look something like this:


public class OutOfMemoryErrorHandler
{
    public void handle(Throwable thrown)
    {
        if (thrown instanceof java.lang.OutOfMemoryError) {
            System.gc();
            JOptionPane.showMessageDialog(null, "FATAL ERROR: Not Enough
Memory!");
        } else {
            thrown.printStackTrace();
        }
    }
}

You might want to release memory heavy resources by
JSVGComponent.setSVGDocument(null) at this point.

Hope this helps with the Out of Memory issue.

-tomas


----- Original Message -----
From: Potts, David
To: [EMAIL PROTECTED]
Sent: Tuesday, September 16, 2003 4:02 AM
Subject: OutOfMemory exception


I am developing a tool that displays a SVG image(SVGCanvas), after doing 3-5
enlargements I get an Out of Memory exception, a check with
freeMemory()/totalMemory() indicates that there is still a sizable amount
memory available.

I am aware that Batik works on an alternative stack is there any way of
catching the OutOfMemory exception?

Is there a better solution to scrolling a SVG image than to use a SVGCanvas
in a scrollable Panel, I did think about using a JViewport and getting batik
to perform the scrolling, but that seems to be using a sledge hammer to
crack a walnut?

Regards

David.



****************************************************************************
*******
This email, its content and any attachments is PRIVATE AND
CONFIDENTIAL to TANDBERG Television. If received in error please
notify the sender and destroy the original message and attachments.

www.tandbergtv.com
****************************************************************************
*******

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

Reply via email to