Java JVM Heap Size

I have an application that at startup requests a certain amount of RAM using the following command.

java -Xms512m -Xmx985m -jar someJarfile.jar 

This command does not run on my computer with 8.0 GB of RAM, because it cannot create a bunch of objects of the specified size. If I lower the maximum range to less than 700 MB, it works fine.

Even stranger, even the execution of simple java -Xmx768m -version fails when the value of the -Xmx flag exceeds 700 m. I try to run it using Java 1.7Uu67 32-bit (this is what the jar was built with), and even newer versions of Java 1.7 and event Java 1.8. I would understand if the maximum heap was higher, and I used 32-bit, but it is not higher than the cap ~ 1.4 GB of 32-bit java

Is there a configuration parameter that I am missing somewhere that can cause this, some kind of software that may interfere? It makes no sense to me why I cannot allocate 700 MB of RAM on a machine with 8.0 GB of RAM. I

I should also note that no other processes are running that take up all of my RAM. This is a new version of Windows 7.

+4
source share
3 answers

While 700 MB is quite low, this is not surprising.

The Windows XP 32-bit emulator in Windows works the same as Windows XP with all limitations. This means that you lose 2 GB or the potential of 4 GB for the OS. This means that already running programs use the virtual memory space. Also, if your program uses shared libraries or heap storage, such as direct memory and memory mapped files, this means that you will lose virtual memory for the heap. Effectively, you are limited to 1.4 GB of virtual memory for your applications, no matter how much memory you actually have.

An easy way to use this is to use the 64-bit JVM, which runs on your 64-bit OS, and is also limited, but instead has 192 TB of virtual memory on Windows.

+4
source

You should try using the 64-bit Java Runtime. It is likely that the 32-bit address space of your computer does not have 985 MB of free memory (4 GB 32-bit address space). When you use the 64-bit Java Runtime, Java can allocate memory in a 64-bit address space, in which free memory is much more accessible.

It doesn’t matter that your JAR file was created using the 32-bit version.

+3
source

The answer to your question may be that Windows is trying to find an unsatisfactory memory block that is large enough: see http://javarevisited.blogspot.nl/2013/04/what-is-maximum-heap-size-for-32 -bit-64-JVM-Java-memory.html . (Although this suggests that other processes are clogging up memory, which seems to contradict your last point.)

+2
source

All Articles