JVM works as its own process, in this regard: JVM requests memory from the OS, which can allocate it either in RAM when swapping.
The memory that you can allocate in java does not depend on your RAM, but on the -Xmx command-line -Xmx that you specify when starting your JVM. If there is not enough memory in RAM, the JVM gets it from swap and (I think) I donโt even know about it.
but
- on some operating systems (Windows XP), the limit is 4G.
- the heap in the JVM is not designed to work with disk.
- swap is limited.
If you need to work with big data, you need to work with BigMemory products (EhCache or Terracotta).
Finally, run jvisualvm or with prameter -verbose:gc to see the heap selection.
source share