2

I have got a problem. My program is really big and java is throwing OutOfMemoryException. In .bat file, I have got the following:

java -server -Dfile.encoding=UTF-8 -Xmx1500m -Xbootclasspath/p:../libs/l2ft.jar -cp config/xml;../libs/*; l2ft.gameserver.GameServer

Java is using 6 GB of my RAM, next 6 GB is not used.

I typed System.getProperty("sun.arch.data.model"); and it says that I am using 64-bit JVM.

2
  • Try increasing Xmx (max heap). Your current setting is a just under 1.5GB. Commented Sep 16, 2012 at 14:09
  • How do you know that it is using 6GB of RAM? and what do you mean by "next 6 GB is not used"? Commented Sep 16, 2012 at 14:09

2 Answers 2

4

You have set the maximum heap size to 1500m and while the JVM can use a little more than that ~200 MB, that's all you limited the process to.

Try instead to limit your progress to around 5 GB. (You want to leave some memory for overhead and the OS)

-mx5g
Sign up to request clarification or add additional context in comments.

Comments

0

Make the options before Xbootclasspath this:

java -XX:MaxPermSize=512m -server -Dfile.encoding=UTF-8 -Xmx8g -XX:+UseCompressedOops

This will make it use more memory and will also make sure it uses as little memory as possible to address the objects in a 64bits machine.

The -XX:MaxPermSize=512m makes the perm gem space larger (which you will probably need as you're using a lot of heap memory) and the -XX:+UseCompressedOops will make it use 32bits addressing for objects, instead of 64bits, as a 8gb heap can be correctly addressed with 32bits, so it makes you use less memory for allocating objects.

3 Comments

I'm curious, why did this get downvoted? Is there something wrong with this answer?
Who knows? There was another answer that was also correct and got downvoted. Looks like the owner deleted it.
IMHO setting MaxPermSize in this case is somewhat premature opitimization. There is no indication so far, that topic starter suffers from insufficient PermGen.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.