Maximum Java heap size of a 32-bit JVM on a 64-bit OS

前端 未结 17 2195

The question is not about the maximum heap size on a 32-bit OS, given that 32-bit OSes have a maximum addressable memory size of 4GB, and that the JVM\'s max heap size depen

17条回答
  •  既然无缘
    2020-11-22 07:15

    The limitation also comes from the fact that for a 32 bit VM, the heap itself has to start at address zero if you want all those 4GB.

    Think about it, if you want to reference something via:

    0000....0001
    

    i.e.: a reference that has this particular bits representation, it means you are trying to access the very first memory from the heap. For that to be possible, the heap has to start at address zero. But that never happens, it starts at some offset from zero:

        | ....               .... {heap_start .... heap_end} ... |
     --> (this can't be referenced) <--
    

    Because heap never starts from address zero in an OS, there are quite a few bits that are never used from a 32 bits reference, and as such the heap that can be referenced is lower.

提交回复
热议问题