HotSpot can't change the type of an Object, it may reorder the operations
and will definately speed things up, but it won't automatically rewrite your
code to be more efficient.
(*Chris*)
----- Original Message -----
From: Tim Crook <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, August 16, 1999 12:32 PM
Subject: Re: (SUGGESTION) OutOfMemoryException
> Hi Giovanni.
>
> I know this is recommended general practice for Strings, but if you are
> using JDK 1.2, wouldn't using HotSpot eliminate the need for hand
optimizing
> code like this?
>
> -----Original Message-----
> From: Giovanni Az�a [mailto:[EMAIL PROTECTED]]
> Sent: Monday, August 16, 1999 1:02 PM
> To: [EMAIL PROTECTED]
> Subject: (SUGGESTION) OutOfMemoryException
>
> Hi,
>
> Avoid concatenating several strings toguether using += (+)
> instead use
> StringBuffer.append method. This is just an advice to
speed
> up SERVLETS ...
> also avoid unnecessary creation of objects ( NEW )
specially
> when processing
> requests because JVMs can allocate in the heap JUST ONE
> OBJECT at the
> time!!!
>
> // What I have been doing earlier
> String sqlQuery=null;
>
> // a very complex select created dynamically based on user
> selected options
> sqlQuery+="SELECT ...."
> ...// LOT OF sqlQuery+=""
>
> the code above when run turns in:
> sqlQuery = new StringBuffer().append("SELECT
> ....").toString();
> sqlQuery = new StringBuffer(sqlQuery).append("
> ....").toString();
> // allocating one StringBuffer in the heap for each
> concatenation!!!!!!!!!!!!
>
> Instead create just one StringBuffer:
> // What I do after I finish reading "JAVA SERVLET
> PROGRAMMING"
> StringBuffer sqlQuery= new StringBuffer();
> String result=null;
>
> sqlQuery.append(" SELECT ....");
> sqlQuery.append(" ....");
> result= sqlQuery.toString();
>
> I FOUND THE TIP IN THE O'Reilly "JAVA SERVLET PROGRAMMING"
a
> great book (if
> not the best) to get started with servlets...
>
>
>
>
>
>
> Giovanni Az�a Garc�a.
> Bachelor in Computer Science.
> Banking and Economic Information Center
> e-mail: [EMAIL PROTECTED]
> ICQ# 20725388
>
>
> Giovanni Az�a Garc�a.
> Bachelor in Computer Science.
> Banking and Economic Information Center
> e-mail: [EMAIL PROTECTED]
> ICQ# 20725388
>
>
> Giovanni Az�a Garc�a.
> Bachelor in Computer Science.
> Banking and Economic Information Center
> e-mail: [EMAIL PROTECTED]
> ICQ# 20725388
>
>
>
___________________________________________________________________________
> 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
>
>
___________________________________________________________________________
> 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
>
___________________________________________________________________________
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