Hi  Khurram,

Khurram Zaman <[email protected]> wrote on 10/14/2009 07:22:08 AM:

> I would like to show you a sample SVG which is loaded by our software. 

    I see this a lot in your document:

      <clipPath id="clip_text1100">
          <text y="349" x="256"
                transform="matrix(1.0 0.0 0.0 1.0 467.1178 -254.12196)"    
 
style="fill:#000000;stroke:black;stroke-width:0;font-family:Verdana;font-weight:normal;font-style:normal;font-size:12;shape-rendering:crispEdges;stroke-dasharray:0,
 
0;"
                startOffset="0" prevfill="#000000" changeflag="true">
              ##
          </text>
      </clipPath>
      <text y="349" x="256"
 
style="fill:#000000;stroke:black;stroke-width:0;font-family:Verdana;font-weight:normal;font-style:normal;font-size:12;shape-rendering:crispEdges;stroke-dasharray:0,
 
0;"
            startOffset="0" prevfill="#000000" id="bg"
            changeflag="true">
          ##
      </text>
      <rect y="86.15416" x="723.1178" width="17.35638427734375"
            transform="matrix(1.0 0.0 0.0 1.0 -467.1178 254.12196)"
            style="fill:black;stroke:none;visibility:hidden;" id="fg"
            height="8.723876953125" clip-path="url(#clip_text1100)"/>

    Which seems like you have at least two copies of the geometry.
Also using a clip-path is perhaps one of the more expensive way to 
draw text.

> Is there any way that I can remove the creation of objects which 
> are not to be used by us. Also if this is so then what is the best 
> way to go about it. How should I identify what objects are being 
> created and not being used and how can I remove their creation? 

   So you can set the display property to 'none' which will prevent
Batik from creating graphics nodes.  You can also remove elements 
from the DOM tree, which will prevent Batik from needing to handle
CSS for those elements.

> I would also like to tell you how we are using transformations. Our 
> application in real time and we have values coming every second. We 
> animate the SVG according to those values per second (or even faster
> if the values come faster). When we do so, the memory consumption 
> keeps rising and the objects dont get de-allocated.

   Do you know what objects aren't getting de-allocated?  In the
past our memory leaks have almost always had to do with adding/removing
elements from the Document - which you don't mention doing.

> How can I reduce the objects being created in batik. 

    For the things you mention we shouldn't be creating very many
graphics node objects for the types of changes you list.

> Usually when the values come we perform setProperty on style attributes 
of 
> repestive shapes. We usually scale the objects, translate them or 
> rotate them depending on the value by setting the transform property. 
> We set visibility through setproperty. 

    If you don't need hidden elements to receive events you can
set display to none (through setProperty).

> We also have event listeners attached to the elements of SVG. 

    Event listeners can cause memory leaks.

> I have set a maximum heap size of 800Mb (which is huge). And our 
> application is expected to run for months. An urgent response would 
> be really helpful since memory stabilization is very important to 
> us. I also wanted to ask you about SVG Salamader and if you have any
> reservations about that library over batik? 

    I don't know anything about SVG Salamander.

Reply via email to