You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by "Potts, David" <DP...@tandbergtv.com> on 2003/09/16 10:02:35 UTC

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
***********************************************************************************


Re: OutOfMemory exception

Posted by tomas lin <to...@hotmail.com>.
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: batik-users@xml.apache.org
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: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Re: OutOfMemory exception

Posted by Thomas DeWeese <Th...@Kodak.com>.
Hi David,

Potts, David wrote:
> 
> 
> 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?

   Someone else posted a response.

> 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?

   Read the archives - subject "JSVGCanvas in JScrollPane again..."
in short Zach DelProposto is working on implementing a scrolling component
on top of the JSVGCanvas - this is the only easy way to avoid the above
problem (you are getting a offscreen buffer the size of the zoomed document!).

> 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: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org