Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Tomcat - JSP/Servlet container
Struts - A MVC web framework
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
JSP - A mailing list about Java Server Pages specification and reference
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Servlet : Session invalidate
Oracle Connection Pooling in 3 2 2
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Running a Simple JMS Example
Tomcat and webapplication specific java library path
Mapping in workers2 properties
org apache jasper JasperException
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action
   MESSAGE
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
Value attribute of <html:checkbox
url string for connecting jboss to oracle
javax servlet ServletException: BeanUtils populate
5 0 18: Windows XP Pro vs Windows 2000
HTTP Status 404 The requested resource is not available
 
-none-

-none-

2007-09-05       - By Peter Warren

 Back
I have a webapp that maintains many concurrent comet connections.
Transmissions between  the client and server are small and infrequent.
I'm trying to lessen the memory usage by playing with buffer
configurations.

To test various configurations, I wrote a client that opens 2000
connections to a comet  servlet.  Each connection sends a short
message and receives a short message back from the server.  I do not
close the connections.

I'm using the NetBeans 6.0 profiler to look at memory use.

The first thing I did was configure the http connector with the
following settings (maybe a little extreme, but I'm just playing
here):

socket.appReadBufSize="512"
socket.appWriteBufSize="512"
socket.rxBufSize="512"
socket.txBufSize="512"

These settings reduced vm heap memory use from 251 MB to 220 MB.

Then I changed my comet servlet to use my own BufferedReader and
PrintWriter with buffer  sizes of 512k, instead of using the Reader
from HttpServletRequest.getReader() and the  Writer from
HttpServletResponse.getWriter(), which both have larger default buffer
sizes.

This reduced memory use from 220 MB to 138 MB.

At this point much of the memory was in char arrays in
org.apache.catalina.connector.InputBuffer objects, and byte arrays in
org.apache.catalina.connector.OutputBuffer objects.  Since I couldn't
find a way to tweak  these buffer sizes with config settings or
external code, I tried modifying the tomcat  code.  I changed the
DEFAULT_BUFFER_SIZE in both those classes to 1024 from 8192.

This reduced memory use from 138 MB to 95 MB.

Now byte arrays in InternalNioInputBuffer and InternalNioOutputBuffer
looked like promising  targets.  To modify these, I changed the
maxHttpHeaderSize in Http11NioProtocol to 1024  from 8192.

This reduced memory use from 95 MB to 66 MB.

At this point my heap map shows the main consumers of memory as follows:

Of the 66 MB on the heap:
char[] account for 26% (below shows %s of the 26%)
 Parameters in Request 56%
 InputBuffer in Request 6%

byte[] 19% (below shows %s of the 19%)
 BufferedInputFilter in Http11NioProcessor 19%
 OutputBuffer in Response 19%
 NioBufferHandler in NioEndpoint 19%
 InternalNioInputBuffer in Http11NioProcessor 20%
 InternalNioOutputBuffer in Http11NioProcessor 18%

So...

1) Are any of the changes listed above bad ideas?  What is the danger
of sizing buffers too small?  Is it just a performance hit, or is
there a danger of losing data?
2) Is there a way for me to change the buffer sizes in InputBuffer,
OutputBuffer, InternalNioInputBuffer, and InternalNioOutputBuffer
without having to change Tomcat code?
3) Does anyone have other ideas for minimizing memory use in a
many-connection, small-data-size webapp?

Thanks,
Peter

-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
To start a new topic, e-mail: users@(protected)
To unsubscribe, e-mail: users-unsubscribe@(protected)
For additional commands, e-mail: users-help@(protected)


©2008 junlu.com - Jax Systems, LLC, U.S.A.