Re: AW: Re: AW: Unnecessary garbage

2007-01-26 Thread Thomas Kathmann
Wyss Patrick wrote: ... generating unnecessary String objects ... // to log a new message buf.clear(); buf.append("some string here"); this creates a String object on every call as well... it's the same as: buf.append(new String("some string here")); how much would you bet :-] I wrote

AW: Re: AW: Unnecessary garbage

2007-01-24 Thread Wyss Patrick
> > No, I don't think so. "some string here" is a constant. It gets > > interned. No new object gets created on each call. The String gets > > created once when the class loads. > > how much would you bet :-] > ooops i guess i was wrong here :-} apologies for opening my big mouth ;-) --

AW: Re: AW: Unnecessary garbage

2007-01-24 Thread Wyss Patrick
> Internally, I'm sure the info() method is calling Object.toString(), > which does create a new String object. you are right Layout.format will turn it into a String. smart appenders do this using StringBuffer/Builder. format could format to a StringBuffer/Builder but this does not realy matte

Re: AW: Unnecessary garbage

2007-01-24 Thread Chris
Wyss Patrick wrote: Why does the logger force you to use Strings? no body is forced to log *strings* have a look at the signature of Logger.info(): public void info(Object message) Internally, I'm sure the info() method is calling Object.toString(), which does create a new String object.

AW: Unnecessary garbage

2007-01-24 Thread Wyss Patrick
> Why does the logger force you to use Strings? no body is forced to log *strings* have a look at the signature of Logger.info(): public void info(Object message) so use StringBuffers (or if using java1.5 StringBuilder) if you like to. however IMHO your code is generating unnecessary String o

Re: Unnecessary garbage

2007-01-23 Thread Curt Arnold
char array or a StringBuffer to build it. These buffers can be reused. A String, on the other hand, always creates unnecessary garbage. Am I crazy, or was this just a poor design decision? It seems pretty clear that there ought to be a method like this: // initialized once StringBuffer buf =

Unnecessary garbage

2007-01-23 Thread Chris
buffers can be reused. A String, on the other hand, always creates unnecessary garbage. Am I crazy, or was this just a poor design decision? It seems pretty clear that there ought to be a method like this: // initialized once StringBuffer buf = ... // to log a new message buf.clear(); buf.appe