Hey guys,

Deserialization of our model (using XStream) currently requires upwards of 
500mb of memory. I’ve been tasked with fixing this since, in the worst case, 
our model is a matrix with an upper bound of 10,000 rows and 1,000 columns 
(10mb big).

Looking at our deserialization process under the profiler, I noticed that 
XStream’s xpath map was consuming upwards of 95% of that space. Digging in a 
little deeper, I noticed the XPath map keeping paths to Booleans and Integers.

What’s the purpose of keeping an XPath entry to an instance of an immutable 
type?

In other words, If I had

class XPathAnnoyer{
    public Integer x; //using Object Integer, an immutable type.
    public Integer y;
}

Integer intInstance = new Integer(20);
XPathAnnoyer instance = new XPathAnnoyer();
instance.x = intInstance;
instance.y = intInstance;

String result = xstream.serialize(instance);

Result would be
<XPathAnnoyer>
    <x>20</x>
    <y>20</y>
</XPathAnnoyer>

and the xpath map will contain the (completely useless entry)
“Integer@ABC123” -> “root/dotdotdot/XPathAnnoyer/x”

So when would that entry ever get used? Why bother keeping it?

My argument against keeping it is that I’m hoping I can get my memory profile 
down significantly.

Let me know if my understanding of this issue is not correct, or if there’s 
some obvious case I’m overlooking.

thanks for any help,

-Geoff

Reply via email to