Is it possible to have multiple heaps in java? If it is possible then in which cases it does happen?
There is already multiple memory regions, but only one Java heap as such.
Typically there are;
ByteBuffer.allocateDirect(4)
See missing [heap] section in /proc/pid/maps for an interesting discussion of the [heap]
region in native space.ByteBuffer.allocateDirect(10000000)
When you say "the heap" this refers to the first one, the one you can naturally allocate Java object on and the Garbage Collector manages. In reality, there is also the native "heap" but this is not interchangeable and has a very different purpose, in fact most Java developers would never need to know it exists.
Note: this is how the JVM is implemented on Windows and Linux, there is nothing in the standard which says these have to exists for Java to work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With