Maximum heap size using for Java process in Windows 10 64 bit running 64 bit JVM

23,498

Solution 1

On a 64-bit machine, with 64-bit JVM you can work with multi gigabyte heaps (dozens and dozens of GBs). I'm not sure it's limited in any way except by the available memory (and the theoretical address space of a 64-bit pointer).

Of course if you're working with a huge heap, the GC has a lot more work to do and you may find that you need to scale horizontally instead of vertically, to maintain a good performance.

If VisualVM isn't showing you using more than 2GB (the initial heap size given with -Xms), then it probably just doesn't need more than that. You've given the permission to use up to 3GB (-Xmx), but the JVM won't allocate more memory just for the fun of it.

Solution 2

Maximum Heap can be allocated for 32bit JVM is 2^32 = 4G, Again 4gb will be devided into 1+ GB for VM to use for runtime classes. It varies windows it is ~2GB and linux it is ~3GB. As you are using 64bit machine maximum heap available is 2^64 it will be big enough for you to run BFS easily.

You can monitor the available memory using vm flags "-XX+PrintFlagsFinal | grep -iE HeapSize" will tell you the maximum available heap size that can be used. Configure slightly less than that and start using...

Solution 3

There is no definite size you could specify for 64 bit architecture but simple test helps you find what is the maximum contiguous space available or could be allocated for a process. This could be tested as follow by using simple command. Try as below java -Xmx -version If the above command gives result then your system could be allowed to have Xmx to that level, If it fails then you can't specify that value.

Few test from system. I tested the value with 20G.40g,100G,160G,300G all these gave java -version output but tried with 1600G that throws the error. Output of the test C:\Users\mpalanis>java -Xmx300G -version

java version "1.7.0_80" Java(TM) SE Runtime Environment (build 1.7.0_80-b15) Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)

C:\Users\mpalanis>java -Xmx1600G -version

Error occurred during initialization of VM Unable to allocate 52431424KB bitmaps for parallel garbage collection for the requested 1677805568KB heap.

Error: Could not create the Java Virtual Machine.

Error: A fatal exception has occurred. Program will exit.

Hope this explanation helps.

Share:
23,498
Brother
Author by

Brother

Updated on July 09, 2022

Comments

  • Brother
    Brother almost 2 years

    What is maximum Heap size for Java process running on Windows 10 64 bits, with 64 bits JVM? My machine has 8 GB of RAM. And I am running Java 8. I trying to run BFS on huge graph for experimental purposes. While running BFS I am monitoring Heap size being used in Java Visual VM. According to Visual VM heap utilization is always less than 2000 MB regardless of providing following JVM parameters

    -Xms2048m
    -Xmx3072m
    -XX:ReservedCodeCacheSize=240m
    -XX:+UseConcMarkSweepGC
    -XX:SoftRefLRUPolicyMSPerMB=50
    -ea
    -Dsun.io.useCanonCaches=false
    -Djava.net.preferIPv4Stack=true
    -XX:+HeapDumpOnOutOfMemoryError
    -XX:-OmitStackTraceInFastThrow
    

    I did some research over internet but could not find any specific answer related to the system specification I am using. Can a java process use more than 2 GB on Windows 10 64 bit and 64 bit JVM? As Guidelines for Java Heap sizing the limit for Windows XP/2008/7 is 2 GB.

  • Eugene
    Eugene about 7 years
    that's not a bad answer at all, may be just explain what Xmx and Xms is... one plus
  • Holger
    Holger about 7 years
    Even if you enforce the allocation of more memory, e.g. via -Xms, it doesn’t imply that the JVM will be using it. If the application doesn’t need it, there is no way to force it to use it (and where was the sense in that, if it was possible?).
  • Brother
    Brother about 7 years
    Actually I am getting OutOfMemoryError on Java heap space regardless of the fact that I am specifying 3GB and my java process cannot occupy more than 2GB before it crashes.
  • Brother
    Brother about 7 years
    thank you for the command, I have tested it on my machine and I can see output of 'java -Xmx650 -version' and above 650 gives error for me.
  • Kayaman
    Kayaman about 7 years
    @Brother That implies that you're not running in a fully 64-bit environment.