Problem with StringBuffer
Maurizio DE CECCO
maurizio at mandrakesoft.com
Wed Mar 29 00:39:25 PST 2000
Tatu Saloranta <tatu at hypermall.net> writes:
> I have a lexer (made with JFLex), that uses StringBuffer for
> constructing the strings for certain tokens.
[ ... ]
I had the same problem some times ago, with an old version
of the Jacl interpreter on the Sun JDK 1.1.something; in that case it was
really dramatic, because the 'big' token there was around 64K;
this also simplified indentifing the problem ;->
In my case, the workaround was to copy the string (with a explicit
call to the String(String) constructor ...
> Any ideas?
I think the actual problem is not in the StringBuffer size, but in the
copy done when the buffer is un-shared; after all, unless the StringBuffer
jump down from 1Mb to 1 byte, a single instance would not be a big problem;
but having many tokens with a lot of wasted memory would be ...
Maurizio De Cecco
More information about the kaffe