> That your finalize method is called, doesn't mean that
> the garbage collector has released your objects. The 
> only way to be shure that this happens, is to explicitly
> run System.gc().

Even that's not sufficient: it just suggests to the VM that
garbage-collecting might be a good idea right now.  Any actual garbage
collection would take place later, in another thread.

And, even when it does happen, that doesn't mean all the memory will
necessarily be released to the OS: the VM will hold on to some so that it
won't need to go back to the OS on the next allocation.

You might want to get a memory profiler (like JProbe) and see where the
memory is going.  At the very least, try doing something like,

        Runtime rt = Runtime.getRuntime();
        System.err.println("Free="+rt.freeMemory()+",
total="+rt.totalMemory());

often, to see how much memory is actually in use, and how much is just
allocated from the OS.

                                                            -- Bill K.


> -----Original Message-----
> From: Ralph Einfeldt [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, May 03, 2001 5:51 AM
> To: '[EMAIL PROTECTED]'
> Subject: AW: Memory usage
> 
> 
> That your finalize method is called, doesn't mean that
> the garbage collector has released your objects. The 
> only way to be shure that this happens, is to explicitly
> run System.gc(). Otherwise it's up to the VM when it will
> free the memory. (Sun's JDK per default only releases
> memory if otherwise an OutOfMemoryError would occur, so
> unless you reach this border the VM will constanly grow)
> 
> See also the options for the JVM:
>   -verbose:gc (Any VM)
>   -Xincgc (Sun SDK 1.3.*)
>   -Xms (Sun + IBM)
>   -Xmx (Sun + IBM)
> 
> -----Ursprüngliche Nachricht-----
> Von: Garry De Toffoli [mailto:[EMAIL PROTECTED]]
> Gesendet: Donnerstag, 3. Mai 2001 14:34
> An: [EMAIL PROTECTED]
> Betreff: Memory usage
> 
> <snip/>
> I have in trouble with the memory usage with Tomcat 3.21, WinNt 2000 
> and Jdk 1.3 of Sun. the problem is that any operation does 
> not release 
> the memory occuped; to control the memory usage I use the 
> Task Manager;
> when Tomcat start, the memory used from the process Java is of 9608 K;
> when I request a Jsp page that has an error, like a variable 
> not declared, 
> the memory used is 11868K; if I wait for 1 ay also, this 
> value does not 
> change, so the memory used is not released,
> 
> running a correct Jsp page, the memory used increase, and this is not 
> released yet; 
> I have written a log on the finalize method of my class, and this is 
> called, so the garbage collector release all my object.
>  
> This behavoir is normal? 
> Probably changing the version of Tomcat this problem may be corrected.
> <snip/> 
> 

Reply via email to