[jdom-interest] JDOM && Jaxen

Elliotte Rusty Harold elharo at metalab.unc.edu
Wed Aug 1 13:14:03 PDT 2001


At 2:59 PM -0400 8/1/01, bob mcwhirter wrote:
>Yah, even without getParent(), though, not using flyweights on the
>Namespaces would help.
>
>In a given document, how many times do you typically see the exactly
>same namespace decl?  Is it worth the overhead of flyweighting them?
>

Please distinguish between namespaces and namespace declarations. Which one is causing you trouble? The reason JDOM flyweights namespaces is because every element and some attributes has a namespace object. Namespaces are not just attached to the elements where you find xmlns atttributes. The memory overhead is significant. 

Still, I wonder if it wouldn't save a lot of that to just intern the strings used inside namespaces. For that matter, how much interning is done now, perhaps even in the parser before we get a hold of element and attribute names? Maybe we should be interning all strings that are used as names of things? That could save beaucoup memory, and perhaps allow us not to use a flyweight pattern on namespaces, if that's really causing people problems. 
-- 

+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+ 
|          The XML Bible, 2nd Edition (Hungry Minds, 2001)           |
|              http://www.ibiblio.org/xml/books/bible2/              |
|   http://www.amazon.com/exec/obidos/ISBN=0764547607/cafeaulaitA/   |
+----------------------------------+---------------------------------+
|  Read Cafe au Lait for Java News:  http://www.cafeaulait.org/      | 
|  Read Cafe con Leche for XML News: http://www.ibiblio.org/xml/     |
+----------------------------------+---------------------------------+



More information about the jdom-interest mailing list