I have a .JAR that apparently uses up too much memory, and throws an exception "Java heap space" (or something similar).
So I tried running the .JAR via the CMD like this:
C:\MyFolder>javaw -jar MyJar.jar -Xms64m -Xmx128m
That did not solve the problem. Same error. Now, when I checked the Processes tab in the windows task manager, I noticed that the process of my jar has a lot less memory than what i asked for (same as running it without the parameters).
Why is it ignoring the parameters?
Also, I think the exception is thrown around the time the process reaches 100mb of memory usage. Is it possible that the GC is trying to free up the memory and that's what causes the problem? Is there any parameter I can set for the GC to prevent that?
Thanks, Malki :)
The Command
will use -Xms... and -Xmx... as parameters to the "main(String[] args)" method.
Parameters to the JVM must be passed before the -jar part:
The reason for that can be seen when we execute "java -version" :
Where your parameters -Xms... and -Xmx... are options to the JVM.