geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Mahieu <m...@twistedbanana.demon.co.uk>
Subject Re: Logging code and Garbage Collection
Date Tue, 12 Aug 2003 23:12:33 GMT
Adam Jenkins wrote:

> I understand the motivation for large scale stuff like that...but your 
> thoughts on simple concats?
>
> e.g. log.debug("Here is some stuff that happened" + someStuff);
>
> Just out of interests, did your profiling pick up less or more time 
> spent in that than wrapping it in a debug?
>
Our conclusion was that it was best just to get into the habit of 
wrapping all log statements (except maybe error and warning depending on 
your p.o.v).  In an example like yours, even if the message isn't output 
3 things happen:

1) The creation of new (temporary) objects
2) Entering the method and executing any code there
3) Garbage collection of the temporary objects

While point 2 may be pretty insignificant depending on the actual 
logging library in use (and other factors) points 1 and 3 certainly aren't.

After all, all that the VM has to do if you wrap the code is check a 
boolean (which it may well have inlined).  If it's false it doesn't do 
1, 2 or 3.

Mark


Mime
View raw message