pradeep wrote:

> Hi Experts,
>
> I found this behaviour with my JServ
> installation(JServ1.1b1/Apache1.3.9/RHLinux6.0/JDK1.2Pre2-Green threads with
> no JIT compilers).
>
> Somebody please explain me the reasons. Hope Apache People can give me more
> details.
>
> I am accessing the simple "Hello" and "IsItWorking" servlets and when
> monitored with "top" , seeing the "SIZE, RSS" for all "httpd"(except the
> main Apache process) and "java" processes increasing and never coming down.
>

This is not unusual.

>
> I read the Apache documentation which says that
>       "When servlet service() method is over and all output data has been
> passed to the client, JServConnection closes the socket connection,
> indicating the termination of the request process. Returning from its run()
> method causes both the thread and the  class itself to be garbage
> collectable."
>

That comment is actually out of date, but even if it were true, you are not
correctly understanding how garbage collection works in most JVMs.  See the
next comment.

>
> If the "child httpd processes" are answering the "client requests" , the
> allocated memory should be garbagge collected. Then I should see some
> decrement in the "SIZE, RSS"values which is not happening.
>

What actually happens in garbage collection is totally up to the author of the
JVM, as long as it conforms to the Java Language Specification.  In general (at
least up through Sun's JDK 1.2.1 or so), garbage collected Java objects are
returned to the Java heap (so the space can be re-used by later object
creations), but memory is *never* returned to the operating system.  Thus, you
will see the SIZE value continue to increase, and never decrease (RSS is the
size of the working set currently in memory -- it will go up and down if the
total memory requirements of your currently running processes exceeds physical
memory and the OS starts swapping stuff in and out).  I saw some notes in
either the JDK 1.2.2 or JDK 1.3 beta documentation that, under certain
circumstances, the JVM will in fact try to return memory to the operating
system; but I've not observed it because I'm not running those revs.

For the HTTPD processes, it depends on how the malloc() and free() calls
ultimately used inside Apache are implemented by the C runtime library being
used -- but, in general, you will see the same thing.  Memory is added to the
heap when necessary, but is never returned.

>
> Is this becoz of the bugs in any softwares, configuration problem?
>

It's not a bug -- that's the way heap-based memory allocation systems work.

If you want to limit the maximum size of the Java process, you can set the
maximum heap size with a command line parameter (passed via
"wrapper.bin.parameters" in jserv.properties for Apache JServ).  For example,
I've got a machine with a gigabyte of physical memory, and I pass a "-mx512m"
command line switch to limit the Java heap to a maximum of 512 megabytes (the
app caches a lot of stuff from the database to improve response times).  If my
allocated objects at any point in time ever exceed that limit, the JVM will
through an OutOfMemoryError exception.

> -pradeep

Craig McClanahan

___________________________________________________________________________
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