JVM Memory Leak

M

mon Gars

Hi,

Using System.gc(),I manage to have a stabil Memory use for my Java application.

Nevertheless is the Memory Use displayed in the Windows Task Manager increasing.

Is there any global parameter limiting the JVM OS Resources ?
 
M

Michael Borgwardt

mon said:
Using System.gc(),I manage to have a stabil Memory use for my Java application.

You should never call System.gc() directly. The JVm does it automatically when
necessary.
Nevertheless is the Memory Use displayed in the Windows Task Manager increasing.

Then perhaps your application contains a memory leak, i.e. somehow holds on to
objects that are not useful anymore.

Or the JVM is postponing garbage collection because it thinks that there's
still enough free memory.

Is there any global parameter limiting the JVM OS Resources ?

Sun's java command has the -Xmx option which sets the maximum heap
size the JVM is allowed to use. I think the default is 64 MB.
 
B

Ben_

As Michael stated, it's indeed considered bad practice to use System.gc().

As regards the memory usage increase it does not *necessarily* denote a
leakage, because the process size reported by the Task Manager is not
exactly equal to the Java heap size. There are different reasons to this,
among which the fact that the JVM consumes some memory and because there are
JVM implementations (not sure all do this, but at least the IBM JVM does)
which do not release the memory at the OS level when objects are freed (and
thus the process size does not decrease even when the heap has compacted).

I found the IBM JVM Diagnostics Guide
(http://www-106.ibm.com/developerworks/java/jdk/diagnosis) helpfull to
understand how object allocation and garbage collection work. I believe it's
worth reading even if you use another JVM implementation.

Obviously, if you have suspicions of leakage you can investigate.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top