users@jaxb.java.net

String interning

From: Kenny MacLeod <kennym_at_kizoom.com>
Date: Mon, 18 Aug 2008 15:22:01 +0100

Folks,

On a hunch, I just tried adding to my hand-written JAXB binding a java
type adapter which calls intern() on each String as it is unmarshalled
on to the object model.

This reduced the heap size of the resulting object graph from 22meg to
8meg. It also increased the time to unmarshal the 8meg XML file from
1.5s to 2.7s, which is fair enough.

My question is whether there is a hidden option in the RI somewhere
which will automatically intern the strings for me, removing the need to
attach these type adapters all over the shop.

In cases where you're binding large reference data sets, the initial
start time is sometimes less important than the memory footprint.

kenny