> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of 
> Richard Eckart
> Sent: 01 November 2006 23:24
> To: dom4j-dev@lists.sourceforge.net
> Subject: Re: [dom4j-dev] Bringing dom4j up-to-date
<snip>

> What I keep thinking about is if it makes sense to intern() 
> all element names and attribute names etc. or install 
> something like a global node-type cache to reduce the memory 
> footprint. I didn't check yet if there is a global node-type 
> cache. I believe I saw one for namespaces.
> 

There are existing options, cant remember of the top of my head what, that
allow /encourage the saxreader to intern the references. This does not use
the String.intern() method, but interns the name/values internally (no pun
intended). Clearly this only covers the XML that is read via a SAXReader

If we are to cover the issue where the XML is created via other means, the
major problem that I can see with interning is the implementation in the SUN
JVM. From my understanding of the JVM the String.intern() places the string
into a global pool that is not subject to GC until the String.class is
unloaded (which never happens), and you can get OutOfMemoryException when
the stack  and heap still have plenty of space. I forget what memory block
the intern() method uses. If someone is more familiar with the issues then
please update this

If there is any interning to do then this would seem to be a policy issue
that could be controlled via a delegate, such as a setting on the
DocumentFactory. That way interning could be customised to provide the
appropriate setting for an application, for examples 
        no interning
        String.intern()
        Map based interning
        LRU based such as LinkedHashMap
        Weak or Soft reference based interning 
        custom interning

There is a cache for qNames - which include the eleemnt and attribute names
but if you dont use the factory methods then this can be bypassed.

For the node type cache - not sure what you mean here - is this a cache of
all of the attribute with a specific name/value, for example. If so this can
be done already, with some simple extensions to the DocumentFactory to cache
and re-use attribute/text etc using the ReadOnlyAttribute etc, but this does
limit the functionallity as they are not mutable, and in some situations
Xpath can be significantly slower



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
dom4j-dev mailing list
dom4j-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dom4j-dev

Reply via email to