> From: Qiuli Sun <[EMAIL PROTECTED]>
>
> I have a java3D applet. I used NT task manager to see how much memory it
> consumed. Originally, the appletviewer used 21M. After I created a matrix of
> 15000 x 15000, the appletviewer used 81M. Then I deleted the matrix by the
> setting its reference to be null and I called Sytem.gc(). Five minutes
> later, the appletviewer still used 81M. My question is:
>
> Does the java release its used memory to the system?

I'm not sure how NT behaves, but here is how it works in UNIX: the java program
is an ordinary process as far as the OS is concerned.  When then big matrix is
allocated, java gets more memory for it's heap and the process grows to 81M.
When the matrix is garbage collected its memory is released and added to the
free space on the heap.  The process remains the same size, 81M, but it's
working set, the amount of memory the process is really using, goes down (the
free space on the heap is not part of the working set).  Looking at the process
size is not a reliable indicator of memory usage.

There are two better tools for evaluating your problem.  First, run your program
with the option to java '-verbose:gc'.  This will print out the size of the heap
and the amount of free space on the heap each time the garbage collector is run.
Using this you should be able to confirm that your matrix is getting garbage
collected.  If you don't see the free space go up after you delete the reference
to your matrix, you may have an unintended reference to the matrix that you
still need to get rid of.  An excellent tool for tracking down this kind of
problem is OptimizeIt, available at http://www.optimizeit.com. The heap analyzer
in OptimizeIt can be used to track down all the references to the matrix.

Hope this helps,

Doug Gehringer
Sun Microsystems

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to