commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sandy McArthur" <sandy...@apache.org>
Subject Re: Log4j String buffer memory Leak.
Date Wed, 07 Jun 2006 16:40:19 GMT
Naveen,

That sample code will result in a String being passed to debug or
info. The StringBuffer used internally by the compiler will be
available for garbage collection after the StringBuffer is converted
to a String and before the resulting String is passed as a parameter.

There isn't a memory leak there as much as maybe wasted work done in
object creation to create the method parameter. Using the if
(logger.isDebugEnabled()) idiom Oliver suggested will save that work.

I'm not familar with Mercury but if it really reports a leak there
then it's probably false positive.

On 6/7/06, Naveen <naween18@yahoo.com> wrote:
> Hello all,
>
>   Iam not sure if there is really amemory leak in Log4jLogger. We use Mercury diagnosis
tool to find the memory leak and the reports show all the string buffers being held up at
>
>   1. org.apache.log4j.Logger.debug
>   2. org.apache.log4j.Logger.info
>
>   this is one of the call we make
>
>   logger.debug(connectionID + "-" + message);
>
>   logger is an instance of Log4j.Logger and connectionID,message are strings
>
>   i know appending strings will internally create StrinBuffers but our memory reports
show string buffers are never cleared which are areated during that call.
>
>   any help is highly appreciated.
>
>   Thanks,
>   Naveen.
>
>
>
>
>
>
>     Naveen
>
>   It only takes a moment to be kind, but the results can be everlasting.!!
>
>
>
>  __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>


-- 
Sandy McArthur

"He who dares not offend cannot be honest."
- Thomas Paine

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


Mime
View raw message