[antlr-interest] Java code generator memory optimization
Martin Probst
mail at martin-probst.com
Sat Sep 24 08:46:05 PDT 2005
Hi,
> If your program lives a long time (like on a server), it's very very bad, as
> strings that are interned are never GC'd.
And it gets even worse if you just take it from a String which is a
substring. E.g. longString.substring(5,10).intern() will in some VMs
make the whole character array from the long string intern'd, e.g.
unavailable to GC. The only thing you should do is new
String(longstring.substring(...)).intern(), as this forces a copy of the
character array.
Martin
More information about the antlr-interest
mailing list