How to limit memory usage of a Java application packaged in a jar (-Xmx doesn't seem to work) on Windows

I would like to limit the maximum heap size for a Java application, but it does not seem to work. I am running an application from a jar package through bat on Windows. Bat Content:

@Echo off
set CLASSPATH=.
java -Xmx32m -classpath %CLASSPATH% -jar MyApplication.jar

This should limit the maximum heap size to 32 megabytes. However, when I do what consumes memory with the application, the Windows task manager shows that the memory consumption is at least about 70 megabytes ... I even tried to use -Xmx2m, but that did not matter.

So I'm not quite sure what the problem is. Of course, a stack, etc. Contained in memory usage, but the memory used by the program should be basically a heap place ...

The Java version looks like 1.6.0_14.

, , , , , .

EDIT: .. , 32M JConsole. ...

,

+5
6

, TaskManager Heap Memory . , .

(, Yourkit) , -Xmx . .

+5

Ummm... .

-Xmx32m , , . , , , JVM, .

+5

. perm -XX: MaxPermSize. , 128 .

java -Xmx32m -XX:MaxPermSize=128m ...
+3

-Xmx128 , OutOfMemoryError. , , , .

+2

, , JVM - ..

, Runtime .

0

All Articles