title: Specify the Java memory allocation pool address
body: <p>With the <code>-Xms</code> and <code>-Xmx</code> Options, it is possible to set the initial and maximum size of the memory allocation pool. Using <em>strace/truss</em> on Linux and AIX I found out, the JVM internally uses the (k)mmap system call. The <em>address</em>-Parameter is NULL, therefore the operating system decides, at which virtual memory address it maps the memory.</p>
  
  <pre><code>$ truss java -Xmx512M Hello 2&gt;&amp;1 | grep mmap
  kmmap(0x00000000, 536870912, 3, 17, -1, 0x00000000, 0x00000000) = 0xB0000000
  </code></pre>
  
  <p>Is is possible, to specify this address?</p>
  
  <p>Background: I have to call legacy code via the Java Native Interface (JNI), which requires huge amounts of non-relocateable data (2 GB in a 32 bit address space) mapped at a specific location in memory. This region overlaps with the location of Javas memory allocation pool.</p>
  
  <p>Edit: This is the actual memory layout:</p>
  
  <pre><code>0x0... AIX
  0x1... Text
  0x2... Stack
  0x3... Heap
  0x4... Heap
  ...... Legacy Data (2 GB)
  0xd... Shared Library Text
  0xe... unused
  0xf... Shared Library Data
  </code></pre>
  
  <p>My goal is to move the Java memory allocation pool from 0xb/0xc into the 0x3/0x4 segments, which is also available in the standard (non large) memory model.</p>