[jdom-interest] Re: carrying user data around with Element
Jason Hunter
jhunter at acm.org
Thu Nov 16 17:03:02 PST 2000
> > > It would basically add the following to the Element class:
> > >
> > > public void setUserObject( Object o);
> > > public Object getUserObject();
> My question was as to whether there
> are substantive objections to adding this?
My primary objection is reducing necessary memory consumption. The most
frequent questions at the XML DevCon meeting yesterday was how "thin"
JDOM was regarding memory usage. I'd like to make sure we can have a
good answer to that question!
As such, I'm concerned about adding a 32-bit pointer to every element.
It seems like a pretty heavy price for something that's not generally
needed and could be solved in other ways. (Looking at one 300K XML file
I have here with 11K elements that would be 44K added memory, or 15% of
the original XML file size.)
Now, just brainstorming here, it would be theoretically possible to do
this:
Object getUserData() {
return GlobalUserDataHash.get(this);
}
This has the advantage that only elements with data take up memory, and
GUDH could use weak refs to enable GC. But that seems like quite a
hack.
-jh-
More information about the jdom-interest
mailing list