You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Edson Alves Pereira <ea...@panamericano.com.br> on 2004/10/08 22:27:52 UTC
StringBuffer memory optimization
Hello folks, i have a problem with StringBuffer, profiling my
web-application i noticed, StringBuffer due to its creation and use consumes
too much memory. Does onyone here know a good way to solve that problem?
Regards,
Edson
Re: StringBuffer memory optimization
Posted by David Wall <d....@computer.org>.
> Hello folks, i have a problem with StringBuffer, profiling my
> web-application i noticed, StringBuffer due to its creation and use
consumes
> too much memory. Does onyone here know a good way to solve that problem?
Not much to go on there, but a key factor to using StringBuffer "well" is if
you can estimate how big the resulting String will be beforehand. This is
because StringBuffer starts out rather small (16 characters as I recall) and
grows as needed. Each time it grows, it has to allocate a new buffer and
copy the previous buffer, so it can be wasteful if misused this way.
So, if you know before, do something like:
StringBuffer buf = new StringBuffer(4000);
Or, if you already have a buffer and you need to add another 500 characters,
you can use:
buf.ensureCapacity(buf.length()+500);
The second will ensure that the buffer is at least big enough to hold its
current contents plus another 500 characters so that if it's not big enough,
it will only do one reallocation as you add up to another 500 characters.
Good luck,
David
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: JK2 configuration
Posted by Debra Bartling <ba...@peer.berkeley.edu>.
At 04:03 PM 10/10/2004 -0700, Daxin Zuo wrote:
> MY system is UNIX (Sparc) tomcat 5.0.28, Apache2.0.43. when I start the
>apache, I get the error in the apache error_log file.
>
>[Sun Oct 10 15:12:24 2004] [error] jk2_init() Can't find child 6351 in
>scoreboard
>[Sun Oct 10 15:12:24 2004] [error] mod_jk child init 1 -2
I had the same problem on Solaris, fixed it by using mod_jk 2.0.4 built
from source and changing to file=anonymous in workers2.properties.
Debra Bartling
Earthquake Engineering Research Center
UC Berkeley
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
JK2 configuration
Posted by Daxin Zuo <dz...@techexcel.com>.
Hi,
MY system is UNIX (Sparc) tomcat 5.0.28, Apache2.0.43. when I start the
apache, I get the error in the apache error_log file.
[Sun Oct 10 15:12:24 2004] [error] jk2_init() Can't find child 6351 in
scoreboard
[Sun Oct 10 15:12:24 2004] [error] mod_jk child init 1 -2
[Sun Oct 10 15:12:24 2004] [error] jk2_init() Can't find child 6352 in
scoreboard
[Sun Oct 10 15:12:24 2004] [error] mod_jk child init 1 -2
[Sun Oct 10 15:12:24 2004] [error] jk2_init() Can't find child 6353 in
scoreboard
[Sun Oct 10 15:12:24 2004] [error] mod_jk child init 1 -2
[Sun Oct 10 15:12:24 2004] [error] jk2_init() Can't find child 6359 in
scoreboard
[Sun Oct 10 15:12:24 2004] [error] mod_jk child init 1 -2
[Sun Oct 10 15:12:24 2004] [error] jk2_init() Can't find child 6354 in
scoreboard
[Sun Oct 10 15:12:24 2004] [error] mod_jk child init 1 -2
my jk2.properties is empty, all are commented.
in my worker2.properties, I have:
[shm]
info=Scoreboard. Requried for reconfiguration and status with
multiprocess
servers.
file=/usr/local/apache2/tomcat5028/logs/jk2.shm
# Defines a load balancer named lb. Use even if you only have one
machine.
[lb:lb]
# Example socket channel, override port and host.
[channel.socket:63.200.135.253:8009]
port=8009
host=63.200.135.253
# define the worker
[ajp13:63.200.135.253:8009]
channel=channel.socket:63.200.135.253:8009
group=lb
In my system, the JSP and Servelt run well, besides the similar error in
error_log.
Please help.
Thanks.
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
RE: PrintWriter is different on Tomcat and Apache?
Posted by Daxin Zuo <dz...@techexcel.com>.
I Solved it. Just response.setContentType("text/html");
-----Original Message-----
From: Daxin Zuo [mailto:dzuo@techexcel.com]
Sent: Friday, October 08, 2004 3:01 PM
To: Tomcat Users List
Subject: PrintWriter is different on Tomcat and Apache?
I have servlets using code like:
StringBuffer sb= new StringBuffer();
AJavaClass.aMethod(sb);
PrintWriter out = response.getWriter();
out.println(bf.toString())
When the servlet is run from Tomcat, it is fine, but if I run it on Apache,
the whole source code is written on the browser, instead display the web
page with qui.
What is wrong? Thanks.
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
PrintWriter is different on Tomcat and Apache?
Posted by Daxin Zuo <dz...@techexcel.com>.
I have servlets using code like:
StringBuffer sb= new StringBuffer();
AJavaClass.aMethod(sb);
PrintWriter out = response.getWriter();
out.println(bf.toString())
When the servlet is run from Tomcat, it is fine, but if I run it on Apache,
the whole source code is written on the browser, instead display the web
page with qui.
What is wrong? Thanks.
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: StringBuffer memory optimization
Posted by QM <qm...@brandxdev.net>.
On Fri, Oct 08, 2004 at 05:27:52PM -0300, Edson Alves Pereira wrote:
: Hello folks, i have a problem with StringBuffer, profiling my
: web-application i noticed, StringBuffer due to its creation and use consumes
: too much memory. Does onyone here know a good way to solve that problem?
That's fairly vague, so all I can say is:
1/ figure out where you're using StringBuffer, and use something else
2/ otherwise, increase the heap space
=)
-QM
--
software -- http://www.brandxdev.net
tech news -- http://www.RoarNetworX.com
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
AW: StringBuffer memory optimization
Posted by Steffen Heil <li...@steffen-heil.de>.
Hi
> There is a known StringBuffer memory leak in a certain version of the jvm
(which I can't remember now offhand). But I'm pretty sure I mentioned on
this list before, so search the archives. (or just wait.. someone will chime
in with the exact version). I think it was around 4.1.2_05 ?
First, you propably mean 1.4.2_05.
Second, no, that's the current 1.4.x one without that error.
I thing 1.4.2_02 hat that.
However 1.5.0 is fine and stable. Upgrade.
Regards,
Steffen
RE: StringBuffer memory optimization
Posted by Mike Curwen <g_...@globallyboundless.com>.
There is a known StringBuffer memory leak in a certain version of the jvm
(which I can't remember now offhand). But I'm pretty sure I mentioned on
this list before, so search the archives. (or just wait.. someone will chime
in with the exact version). I think it was around 4.1.2_05 ?
> -----Original Message-----
> From: Edson Alves Pereira [mailto:eapereira@panamericano.com.br]
> Sent: Friday, October 08, 2004 3:28 PM
> To: Tomcat-User List (E-mail)
> Subject: StringBuffer memory optimization
>
>
> Hello folks, i have a problem with StringBuffer,
> profiling my web-application i noticed, StringBuffer due to
> its creation and use consumes too much memory. Does onyone
> here know a good way to solve that problem?
>
> Regards,
> Edson
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org