commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Dudziak <tom...@gmail.com>
Subject Re: [lang] StringUtils consumes a lot of memory ?
Date Thu, 26 Jan 2006 00:53:13 GMT
On 1/26/06, Stephen Colebourne <scolebourne@btopenworld.com> wrote:

> Doesn't look anything wrong here...
>
> private static final String[] PADDING = new String[Character.MAX_VALUE + 1];
>
> static {
>    // space padding is most common, start with 64 chars
>    PADDING[32] = "                  ";
> }
>
> or in the padding method...
>
> String pad = PADDING[padChar];
> if (pad == null) {
>      pad = String.valueOf(padChar);
> }
> while (pad.length() < repeat) {
>      pad = pad.concat(pad);
> }
> PADDING[padChar] = pad;
> return pad.substring(0, repeat);
>
>
> So, I'm struggling to see what might be happening. Nevertheless, if its
> wrong it needs fixing.

Yup, seems perfectly fine. I didn't debug it yet - can't debug when
profiling, at least not with the default YourKit-generated Tomcat
config - so I'm not sure why the list is completely initialized. I'll
will check tomorrow.
IMHO the easiest solution would be a StringUtilsBean, though. A webapp
(or OJB in this case) then could simply maintain such a bean and later
release it.

Tom

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message