문제

I have a question that bothered me after reading an article on analyzing thread dumps. There was one paragraph which mentioned that the logical maximum heap size in a 32-Bit JVM is 4GB.

This link states that the maximum heap size on a 32-bit Windows machine will be around 1.4 - 1.6 GB.

My question is, say if you have RAM of say around 8GB, does this mean i can only utilize 1.4-1.6 GB of it if i were to you a 32-bit JVM? And what will be the maximum size allowed for a 64bit JVM?

Appreciate your help regarding this as i am confused on the same.

도움이 되었습니까?

해결책

specifically on windows, the reason is a combination of the implementation of hotspot (the sun/oracle JVM) and windows dlls.

32-bit code has access to a 4GB virtual address space (there are extensions that allow more but i wont be going into those).

on 32-bit windows the upper 2GB of this virtual address space are reserved for operating sysem use (some versions of the OS accept the /3GB flag as a boot parameter to allow for 3GB of user-accessible space).

also, any libraries (*.dlls) you use are mapped into parts of this address space. by default the windows base *.dll files are loaded at the ~1.6 GB mark (differs slightly by OS version and patch level)

on top of all this, the hotspot JVM only supports allocating a single, continuous, chunk of memory for use as heap space.

so, if you try and picture this in your head, you'll see that you have a free area of ~2GB with a "wall" of windows *.dlls loaded at ~1.6GB. this is the logic behind that figure. it also means that even if you provide the /3GB flag the sun/oracle JVM will not be able to make use of it. some other VMs are better at handling a fragmented heap - like the jrockit VM

you could also try rebasing windows dlls so that they load into higher memory addresses and squeeze some more usable heap space, but the process is fragile.

also note that its very possible that drivers/applications loaded on a particular machines (like anti virus software) will inject their own *.dlls into a java process, and those dlls can be loaded at ever lower memory addresses, further shrinking your usable heap space.

on 64bit versions of windows the addressable limit is 8-128TB and the physical limit stands at 64TB right now

다른 팁

2^32 = 4GB is the max total memory you can address with 32 bits.

The JVM only gets 1.4-1.6GB on 32 bit machines because you still have to accomodate the operating system.

2^64 = (2^32)^2 is the max total memory you can address with 64 bits. As you can see, it's a much larger number.

jvm and also os use paging memory managment system that obtain 4G virtual memory for us in

32bit os systems

but if you have 8G ram you must use 64 bit version of os for maximum performance of os

It depends on your operating system, 32 bit versions of MacOS X and Linux have some ability to access more than 4GB in the kernel but still limit processes to 4GB. Other operating systems may restrict process memory further since they need part of the 4GB for themselves. In general you want to avoid swapping out your JVM to VM so you need to know how much free memory you system has.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top