title: What is the difference between off-heap, native heap, direct memory and native memory?
body: <p>Recently I came across these concepts while learning JVM internals. I am aware that there are already a lot of questions on SO about them individually, but I still cannot grasp the relationship between them or, simply what they are.</p>
  <p>Now I describe them as such:</p>
  <ol>
  <li><p><strong>Native memory</strong> means the memory area outside normal JVM heap, but still within the total user space memory spared by OS for JVM process (for example on 32-bit Windows it is by default 2 GB). This space is reserved by JVM to store some internal data, such as Permanent Generation / Method Area etc.</p>
  </li>
  <li><p><strong>Direct memory</strong> means you use native memory by means of <code>java.nio.DirectByteBuffer</code>.</p>
  </li>
  <li><p><strong>Native heap</strong> means you use native memory by means of <code>unsafe.allocateMemory</code> or simply do a <code>malloc</code> in your JNI code.</p>
  </li>
  <li><p><strong>Off-heap</strong> is the same as native memory.</p>
  </li>
  </ol>
  <p>And one additional question, is it possible to allocate memory directly outside the total memory space (4GB on 32-bit OS) spared for JVM process?</p>
  <p>Please point out the mistakes in my understanding and if possible, give a clear description about them.</p>