Hi,

This is a guess, I suggest reviewing the garbage collection rules for the
JVM.  I know that you're on the right track by assigning null to the object,
but this does not guarantee that the object will be garbage collected, and
there is no way to guarantee garbage collection will run according to the
specification.  Garbage collection is a low priority thread that only
executes with the JVM thinks it has sufficient time to perform the process. 

I am also wondering if you store your heavy object in the session, as doing
so would cause a reference to the heavy object to exist for the durration of
the session of each thread.  If you are storing the heavy object to the
session, then you'll want a session.remove("ho"); statement in your finally
clause.

Other than that, I cannot think of anything else to do...

-----Original Message-----
From: Wolle [mailto:[EMAIL PROTECTED]]
Sent: Sunday, May 06, 2001 6:46 PM
To: tomcatUser
Subject: My growing memory problem resolved


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

Reply via email to