Hi Thomas. [EMAIL PROTECTED]: > I'm worried that these represent a very significant > Memory leak. How are these managed as documents go > into/out of scope? (think someone twiddling the > xlink:href on an image/use element).
Ok I have investigated this a bit more. Using WeakReferences in the childContexts set does avoid the problem of the resource documents not being GCed if they are subsequently unreferenced before the document ends. However, there is another problem that I have came across while poring over the output from 'hat'. For the case where a dynamic SVG 1.2 document is used as a resource document, it won't be GCed because of some caching going on by Rhino. I've checked in a test that demonstrates the problem (samples/tests/spec/scripting/primaryDoc.svg, referenced from test-resources/org/apache/batik/swing/unitTesting.xml). If you uncomment the script line in primaryDoc.svg you get an appropriate pause to dump the heap. Inspecting the heap for instances of SVG12BridgeContext you'll find the one uncollected one. The "reference chain from rootset excluding weak references" shows that the SVG12BridgeContext (and its document) are referenced from a static member of org.mozilla.javascript.JavaMembers, which seems to be caching various reflections of Java object methods (such as those in the document). The reference comes about because the JS 'parent' property of each of these functions is set to the window wrapper objects, o.a.b.script.rhino.svg12.GlobalWrapper, and that object has a reference to the Window object in the ScriptingEnvironment object. So I'm not sure what to do about this. Despite what to do for a technical solution, I don't know how GC of SVG 1.2 resource documents should be handled. Since they have their own script environments, which could be doing any manner of things in the background, and because of the text in "Externally referenced documents" in [1], I'm not sure that the document should be GCed until the primary document has gone out of scope. Regardless, it would be good to solve the problem with Rhino caching. Thanks, Cameron [1] http://www.w3.org/TR/2004/WD-SVG12-20041027/nonvisual.html -- Cameron McCormack ICQ: 26955922 cam (at) mcc.id.au MSN: cam (at) mcc.id.au http://mcc.id.au/ JBR: heycam (at) jabber.org --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]