Hello Gin!

CG>         But then creating a StringBuffer will result in more wasted space
CG> wouldnt it Chris?

The space is not exactly wasted. You create an extra StringBuffer, use
it as you process the request and then just drop it, forget about it
(if it was a local variable in the doGet() method).

The space is not excatly wasted, but you're going to have the next
garbage collection a bit sooner.

Maybe Chris is right and one StringBuffer is not a big deal really..
But I feel you just do not need it at all... Unless you want to make
use of less IO calls as Chris advises.. Dunno how much gain this
gives..

Maybe we gain a bit if we do less write() calls, but at the same time
the garbagge collection happens a bit sooner. Little loose, little
win!

CG>  Since, if you think about it, your creating one
CG> StringBuffer then writing it's String value out to the Response's
CG> StringBuffer.

Yes, as Matt Penner <[EMAIL PROTECTED]> has noted it is not
really a StringBuffer:
MP> However, what ever your final output is it goes through a buffer before being
MP> sent to the client.  This is entirely dependent on the container and O/S along
MP> with some buffer settings.
But you should not bother about it at all, it is quite invisible to
the web developer :-)  Sure you can customize the servlet container
buffer by size, but this has nothing to do with our current
discussion.

CG> But I know what you mean about avoiding calls to the IO. (I
CG> had an XML parser/generator that timed in at ~ half of its usually running
CG> time just by skipping all debugging statements!!)

Did you have this experience with Cocoon? I had mine. Terrible.
It is after Cocoon that I'm so paranoid on not creating objects when
there's no need to! In my case it was the XSLT processor (Xalan) that
was the real memory+cpu time PIG!!

CG>  Is this a catch 22? :)

Are the good old OutputStreamWriter-s that bad really? Dunno

CG>         How about using code optimizers like DashO?  That usually speeds up
CG> the code a bit (never tried it in a J2EE environment before. But it
CG> definitely speeds up stand alone Swing Java GUIs). I dont think it actually
CG> effects IO though.
CG> -Tim

CG> -----Original Message-----
CG> From: Christopher K. St. John [mailto:[EMAIL PROTECTED]]
CG> Sent: Tuesday, January 29, 2002 11:15 AM
CG> To: [EMAIL PROTECTED]
CG> Subject: Re: Java Servlet HTML


CG> Anton Tagunov wrote:
>>
>> out.write("<html>");
>> generally results in the string being sent right to the user via
>> the underlying socket implementation without any memory allocation.
>>

CG>  Premature optimization is the root of all evil :-)

CG>  Most servlet containers buffer by default, see the apidocs
CG> for javax.servlet.Response, specifically setBufferSize(). So
CG> the String will not generally be sent directly to the
CG> underlying socket implementation.

CG>  In any case, if you're concerned with performance, you want
CG> to avoid calls write() (the Java IO code is notoriously slow),
CG> and the best way to do that is with big buffers.

CG>  Making the code awkward in order to save a few bytes of
CG> memory is something that you should only do if you're
CG> really desperate.


CG> --
CG> Christopher St. John [EMAIL PROTECTED]
CG> DistribuTopia http://www.distributopia.com

CG> ___________________________________________________________________________
CG> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
CG> of the message "signoff SERVLET-INTEREST".

CG> Archives: http://archives.java.sun.com/archives/servlet-interest.html
CG> Resources: http://java.sun.com/products/servlet/external-resources.html
CG> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

CG> ___________________________________________________________________________
CG> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
CG> of the message "signoff SERVLET-INTEREST".

CG> Archives: http://archives.java.sun.com/archives/servlet-interest.html
CG> Resources: http://java.sun.com/products/servlet/external-resources.html
CG> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html


CG> __________
CG> http://www.newhost.ru - ����� ����, �������� ����



- Anton
[EMAIL PROTECTED]
[EMAIL PROTECTED]

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to