Is heap java memory continuous?

I have seen people note that Java Heap is contiguous, and people say otherwise. Well, can someone give me a definitive answer and explain this question? Also, is there some kind of data structure in the Java heap, as it is in Java Stack?

+6
source share
3 answers

Quote from the JVM Specification : Heap memory does not have to be contiguous. Therefore, your code should not make assumptions about heap continuity.

+11
source

The real answer: you do not know and should not worry. There are different JVMs and no one makes any promises for anything other than specification.

+7
source

It depends on the JVM, but it is definitely not guaranteed to be contiguous. HotSpot has been using a bunch of generations, while IBM JDK and JRockit do not. I believe that the sweep / compress algorithm is used in the garbage collection processes of IBM and JRockit, which in practice should lead to an adjacent heap.

+2
source

Source: https://habr.com/ru/post/899551/


All Articles