3

I know that the JVM has some JVM HotSpot memory which is further divided into three areas:

  • Java Heap
  • Permanent Generation Space
  • Native Heap (C-Heap)

I know that Java has automatic garbage collection mechanism for Heap Memory.

So, I want to confirm that in my last statement Heap refers to both Java Heap and Native Heap (C-Heap) or just Java Heap.

Also, what about Permanent Generation Space? Is it also considered as some kind of Heap or what?

1 Answer 1

3

The GC will collect both the Java Heap and the permgen, but not the native heap. The native heap is manually managed by whatever C code owns it. The permgen, on the other hand, is managed by the JVM garbage collector (though not necessarily as efficiently as the rest of the heap, as certain GC algorithms will only compact the permgen when absolutely necessary).

9
  • Does the hot spot compiler even use a heap? All the memory required by an Object should be allocated on the Java Heap. All the native code should need is some stack space for immediate processing. Perhaps someone could clarify. Feb 6, 2015 at 0:46
  • @JamesAnderson the "native heap" is the heap used by native code. For example, when you make certain library IO calls it will call native C code, which will then malloc and free memory to do its business. Feb 6, 2015 at 0:50
  • but surly these calls are made by the main compiled and delivered JVM code. Why should the code generated by the JIT compiler need any heap space? Feb 6, 2015 at 1:46
  • @JamesAnderson I'm not talking about code compiled by the JIT. You know how Java can call out to native code, right? Well that native code obviously can't allocate Java objects, so it has to malloc its own memory. Feb 6, 2015 at 1:50
  • I agree! but the OP was asking about the Hot Spot compiler (among other things!). Feb 6, 2015 at 2:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.