I wonder why the StringUtils Class objects can't be garbage collected.
There should really only be one instance of the StringUtils Class object
after a webapp reload.  The previous one should go away with the
WebappClassLoader when it is discarded.  Correct?  That would mean that we
have a memory leak somewhere. 

-----Original Message-----
From: Thomas Dudziak [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, January 25, 2006 7:20 PM
To: Jakarta Commons Developers List
Subject: [lang] StringUtils consumes a lot of memory ?

Hi folks,

I'm currently investigating a memory leak in a OJB-using application,
and it seems as if StringUtils is the culprit at least in terms of
memory consumption (OJB uses StringUtils#split, #replace and
#indexOfAny).
The problem is as follows: upon reloading a really simple webapp in
Tomcat (5.5.12, Windows XP SP2,  Java 1.5.0_04-b05) 5 times, there are
5 instances of StringUtils (or more precisely, their static fields)
still in the memory (seems Tomcat uses a different classloader for
StringUtils, but that is a different issue).
My problem with StringUtils is now that each of these StringUtils' is
using 262.152 bytes of memory in an array of 65535 strings. After a
bit of digging in the class, it seems as if it retains a string for
every character, and this even if padding is not utilized.
My question is now: is there some way this could be changed ? I'm
thinking along the lines of lazy initialization, or perhaps in the way
BeanUtils handles this (e.g. StringUtilsBean and static StringUtils).

regards,
Tom

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to