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 Ralf Müller <ma...@geomagic.de> on 2003/06/30 14:11:20 UTC

CssEngine issues

Hi!
 
I have a problem. I am not so sure if it resides in Batic or not...
Ok here the description
I have an application which constructs an svg and Displayes it using
Batik. This works fine when using my IDE (Eclipse).
When I use the maven uberjar plugin to create a distribution (copys the
dependent batik jars together with my application jar in one jar) my
application still generates the same svg file, but the display gets the
following error. 
 
java.lang.NullPointerException
                at
org.apache.batik.css.engine.CSSEngine.parseStyleSheet(Unknown Source)
                at
org.apache.batik.dom.svg.SVGDOMImplementation.createCSSEngine(Unknown
Source)
                at
org.apache.batik.bridge.BridgeContext.initializeDocument(Unknown Source)
                at org.apache.batik.bridge.GVTBuilder.build(Unknown
Source)
                at org.apache.batik.swing.svg.GVTTreeBuilder.run(Unknown
Source)
 
My thought is that it might be because I jave the batic jars now
residing in an other jar. Has anybody experienced something similar?
 
Thanks for your help
 
Ralf

Possible Memory Leak rendering PNG images?

Posted by tomas lin <to...@hotmail.com>.
Hi,

There might be a memory leak when rendering embedded images in Batik.

I am working on Windows 2000 SP4  and JDK 1.3.1.

Using CVS Batik from 6/24/03, I start an instance of the JSVGCanvas and set
it to be be dynamic.

I add a node with the following SVG properties:

<image x="0" y="0" width="2700.0" image-rendering="optimizeQuality"
xlink:href="blah.png" height="1813.0" preserveAspectRatio="xMinYMin meet"/>

In this case, blah.png is about 150k. It is a black and white drawing of
size 1813x2700. It has been optimized with the optipng png optimizer.
[ http://www.cs.toronto.edu/~cosmin/pngtech/optipng/ ]

After initial rendering, the app uses ~35 megs.

I do a series of zooms and add more elements. The memory footprint rises to
~100 megs. If I just quit here ( set my SVGCanvas to null ), I see that
memory is never freed.


1. ) I purge the canvas. ( most of this code from Randy Baron's May 5, 2003
post 'JSVGCanvas disposal / memory leak' ).

  public void purge()
    {
        ToolTipManager ttipman = ToolTipManager.sharedInstance();

        ttipman.unregisterComponent(this);
        this.renderer.dispose();
        this.releaseRenderingReferences();
        this.getOverlays().clear();
        this.getInteractors().clear();

        this.bridgeContext.dispose();

        if (this.getUpdateManager() != null &&
this.getUpdateManager().getBridgeContext() != null)
            this.getUpdateManager().getBridgeContext().dispose();

        this.stopProcessing();

        this.getGraphics().dispose();
        this.flushImageCache();
        this.deselectAll();
        this.removeAll();
        this.listener = null;
        this.listenerList = null;
        this.updateManager = null;
        this.accessibleContext = null;
        this.svgDocument = null;
        this.removeMouseListener(mouseListener);

        Runtime.getRuntime().runFinalization();
        Runtime.getRuntime().gc();

        /* in the original code, there  is a nullOut Function, but I want to
retain my SVG's XML,
            so  I do the dispose() call below instead */

    }


2.) After a little tracing, I add a dispose function to
org.apache.batik.gvt.RasterImageNode.

public void dispose{
    this.image = null;        // image in RasterImageNode.java is declared
as protected Filter image;
}

I invoking dispose on the my image node ( blah.png , above )

            ((RasterImageNode)
m_svgCanvas.getUpdateManager().getBridgeContext().getGraphicsNode(m_imageNod
e)).dispose();

m_svgCanvas.getUpdateManager().getBridgeContext().unbind(m_imageNode);

3.) I then add a static function that will invoke flush() on every
BufferedImage object created by PNGRegistryEntry.

At the end of this, I see my memory footprint go down to about 15 megs.



Is there anything else that I can do here to free up more memory?

In particular, there is a 5.5 meg int[] in memory that really bothers me.
This seems to be an Offscreen Image that is referenced by the RepaintManager
(javax.swing.RepaintManager). Is there a way to clear this without disabling
doubleBuffering?

thanks,

-tomas


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Re: CssEngine issues

Posted by Thomas DeWeese <Th...@Kodak.com>.
Ralf Müller wrote:

>I will look more into it and than come back to you.
>But my Document is not from a file it gets constructed in the
>application. From this there should be no difference if I jar everything
>up. (Or am I mistaken there)
>  
>
    The point is that the NPE you are getting is a symptom not the 
cause, but I
can't begin to guess what the cause is without knowing more.

>Thanks for the help 
>
>Ralf
>
>-----Original Message-----
>From: Thomas DeWeese [mailto:Thomas.DeWeese@Kodak.com] 
>Sent: Monday, June 30, 2003 2:39 PM
>To: Batik Users
>Subject: Re: CssEngine issues
>
>Ralf Müller wrote:
>
>  
>
>>Hi!
>>
>> 
>>
>>I have a problem. I am not so sure if it resides in Batic or not...
>>
>>Ok here the description
>>
>>I have an application which constructs an svg and Displayes it using 
>>Batik. This works fine when using my IDE (Eclipse).
>>
>>When I use the maven uberjar plugin to create a distribution (copys 
>>the dependent batik jars together with my application jar in one jar) 
>>my application still generates the same svg file, but the display gets
>>    
>>
>
>  
>
>>the following error.
>>
>> 
>>
>>java.lang.NullPointerException
>>
>>               at 
>>org.apache.batik.css.engine.CSSEngine.parseStyleSheet(Unknown Source)
>>
>>               at 
>>org.apache.batik.dom.svg.SVGDOMImplementation.createCSSEngine(Unknown 
>>Source)
>>
>>               at 
>>org.apache.batik.bridge.BridgeContext.initializeDocument(Unknown
>>    
>>
>Source)
>  
>
>>               at org.apache.batik.bridge.GVTBuilder.build(Unknown
>>    
>>
>Source)
>  
>
>>               at 
>>org.apache.batik.swing.svg.GVTTreeBuilder.run(Unknown Source)
>>
>> 
>>
>>My thought is that it might be because I jave the batic jars now 
>>residing in an other jar. Has anybody experienced something similar?
>>
>>    
>>
>    So it appears that the problem is when it is parsing the User Agent 
>Style Sheet.
>However I think the problem is really lower down than is indicated and 
>the NPE is
>caused when Batik tries to build the SyntaxError message because your
>document is from a stream and it has no documentURI ( see line 940 in
>CSSEngine.java).  You might try replacing  'documentURI.toString()'
>with:
>
>(documentURI == null)?"<document stream>":documentURI.toString()
>
>    And see if you get a better message (you might also stick a ' 
>e.printStackTrace()'
>in the catch to see the real 'source' of the problem).
>
>  
>
>> 
>>
>>Thanks for your help
>>
>> 
>>
>>Ralf
>>
>>    
>>
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
>For additional commands, e-mail: batik-users-help@xml.apache.org
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
>For additional commands, e-mail: batik-users-help@xml.apache.org
>
>
>  
>




---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


RE: CssEngine issues

Posted by Ralf Müller <ma...@geomagic.de>.
I will look more into it and than come back to you.
But my Document is not from a file it gets constructed in the
application. From this there should be no difference if I jar everything
up. (Or am I mistaken there)

Thanks for the help 

Ralf

-----Original Message-----
From: Thomas DeWeese [mailto:Thomas.DeWeese@Kodak.com] 
Sent: Monday, June 30, 2003 2:39 PM
To: Batik Users
Subject: Re: CssEngine issues

Ralf Müller wrote:

> Hi!
>
>  
>
> I have a problem. I am not so sure if it resides in Batic or not...
>
> Ok here the description
>
> I have an application which constructs an svg and Displayes it using 
> Batik. This works fine when using my IDE (Eclipse).
>
> When I use the maven uberjar plugin to create a distribution (copys 
> the dependent batik jars together with my application jar in one jar) 
> my application still generates the same svg file, but the display gets

> the following error.
>
>  
>
> java.lang.NullPointerException
>
>                at 
> org.apache.batik.css.engine.CSSEngine.parseStyleSheet(Unknown Source)
>
>                at 
> org.apache.batik.dom.svg.SVGDOMImplementation.createCSSEngine(Unknown 
> Source)
>
>                at 
> org.apache.batik.bridge.BridgeContext.initializeDocument(Unknown
Source)
>
>                at org.apache.batik.bridge.GVTBuilder.build(Unknown
Source)
>
>                at 
> org.apache.batik.swing.svg.GVTTreeBuilder.run(Unknown Source)
>
>  
>
> My thought is that it might be because I jave the batic jars now 
> residing in an other jar. Has anybody experienced something similar?
>
    So it appears that the problem is when it is parsing the User Agent 
Style Sheet.
However I think the problem is really lower down than is indicated and 
the NPE is
caused when Batik tries to build the SyntaxError message because your
document is from a stream and it has no documentURI ( see line 940 in
CSSEngine.java).  You might try replacing  'documentURI.toString()'
with:

(documentURI == null)?"<document stream>":documentURI.toString()

    And see if you get a better message (you might also stick a ' 
e.printStackTrace()'
in the catch to see the real 'source' of the problem).

>  
>
> Thanks for your help
>
>  
>
> Ralf
>




---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Re: CssEngine issues

Posted by Thomas DeWeese <Th...@Kodak.com>.
Ralf Müller wrote:

> Hi!
>
>  
>
> I have a problem. I am not so sure if it resides in Batic or not...
>
> Ok here the description
>
> I have an application which constructs an svg and Displayes it using 
> Batik. This works fine when using my IDE (Eclipse).
>
> When I use the maven uberjar plugin to create a distribution (copys 
> the dependent batik jars together with my application jar in one jar) 
> my application still generates the same svg file, but the display gets 
> the following error.
>
>  
>
> java.lang.NullPointerException
>
>                at 
> org.apache.batik.css.engine.CSSEngine.parseStyleSheet(Unknown Source)
>
>                at 
> org.apache.batik.dom.svg.SVGDOMImplementation.createCSSEngine(Unknown 
> Source)
>
>                at 
> org.apache.batik.bridge.BridgeContext.initializeDocument(Unknown Source)
>
>                at org.apache.batik.bridge.GVTBuilder.build(Unknown Source)
>
>                at 
> org.apache.batik.swing.svg.GVTTreeBuilder.run(Unknown Source)
>
>  
>
> My thought is that it might be because I jave the batic jars now 
> residing in an other jar. Has anybody experienced something similar?
>
    So it appears that the problem is when it is parsing the User Agent 
Style Sheet.
However I think the problem is really lower down than is indicated and 
the NPE is
caused when Batik tries to build the SyntaxError message because your
document is from a stream and it has no documentURI ( see line 940 in
CSSEngine.java).  You might try replacing  'documentURI.toString()' with:

(documentURI == null)?"<document stream>":documentURI.toString()

    And see if you get a better message (you might also stick a ' 
e.printStackTrace()'
in the catch to see the real 'source' of the problem).

>  
>
> Thanks for your help
>
>  
>
> Ralf
>




---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org