tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wolle <wo...@dorf.RWTH-Aachen.DE>
Subject Re: My growing memory problem resolved
Date Mon, 07 May 2001 10:59:48 GMT
Hei Eric,
thank you for your reply,
i will answer your questions below:

eric chacon wrote:

> Wolle,
>
> I think the problem may lie in your JVM: Setting a reference to the object
> to null does not automatically free the memory--it just allows the garbage
> collector to clear it whenever it runs.
>
> In many (most?) JVMs, garbage collection is single-threaded.  It may run at
> a fairly low priority.

this was tested with JDK1.3.0_02 (Hotspot Server/client) and IBMJava2_1.3

>
>
> Therefore, under stress testing, it is possible for you to eat up a lot of
> memory before the garbage collector has a chance to pool it.

Yes, of course, I gave it a half day an nothing becomes free.
I had also see, that all process was cloesd (tool top under Linux).

>
>
> One way to test this would be to let your process run under high load, and
> then stop your load and watch over time to see if the memory is released.
>
> If, in fact, it is a garbage collection problem, you have a couple of
> choices: 1) upgrade your JVM and see if that helps.  2) pool your Heavy
> Objects:  create a store of them, and re-use them.
>

I have done something else,
I have synchronize the Object and use create only on Object:

class Servlet extends HttpServlet{
     HeavyObject  ho = null;

      public doPost(request,response) throws IOException{
           if (ho != null){
             ho = new HeavyObject();
           }
      }
}

that works,
so the Object will only created once, but I have to synchronize the Object.


>
> If you're doing load balancing/workload management, this might cause some
> problems (you'll need to persist your objects to a common database), but if
> everything's running on one machine, pooling might be an easy, convenient
> solution.
>
> Cheers,
> Eric
>

thanks and Greetings,
Michael

>
> >From: Wolle <wolle@dorf.RWTH-Aachen.DE>
> >Reply-To: mwollenhaupt@web.de
> >To: tomcatUser <tomcat-user@jakarta.apache.org>
> >Subject: My growing memory problem resolved
> >Date: Mon, 07 May 2001 03:45:55 +0200
> >
> >Hello ,
> >i have posted for a few day's a problem thats the Memory usage will
> >extremly grow up when I refresh a page very often
> >The Problem was, that I creat a "heavy memory" Object on each refresh.
> >Normally I have 81 processes run at all, when execute the "stress-test"
> >the processcount will rise till ~ 230. And each new Prcoesses will creat
> >a new Object.
> >When I stop the stress-test, the processcount becomes normal (~ 100) ,
> >but the memory usage won't fall.
> >But the new created Object have now refernces that points to them.
> >But why they don't becomes free ???? My code is somthing like this:
> >
> >public class servlet1 extends HttpServlet{
> >     ..
> >...
> >..
> >..
> >   public void doPost(HttpServletRequest request,HttpServletResponse
> >response)
> >                               throws IOException{
> >         try{
> >            HeavyObject ho = new HeavyObject();
> >         }
> >         finally{
> >            ho = null; // for testing implementet, but this gives the
> >memory not free, also
> >         }
> >
> >   }
> >}
> >
> >Is this a Bug in Tomcat ? Or is it a Bug from me ? Or som Java
> >misunderstood ?
> >Why will the Object not becomes free, when some of the Threads will be
> >closed ,
> >and the only reference is in the closed Thread ?
> >
> >
> >Greetings,
> >Michael
> >
>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com




Mime
View raw message