title: Java - Get JVM memory settings at runtime
body: <p>I have a Java 7 program which launches other Java processes. I would like for memory settings for the original program to be passed along to the child processes.</p>
  
  <p>The processes are launched as follows: </p>
  
  <pre><code>//https://stackoverflow.com/questions/636367/executing-a-java-application-in-a-separate-process
  String javaHome = System.getProperty("java.home");
  String javaBin = javaHome + File.separator + "bin" + File.separator + "java";
  String classpath = System.getProperty("java.class.path");
  String className = MyClass.class.getCanonicalName();
  
  ProcessBuilder pb = new ProcessBuilder(javaBin, "-cp", classpath, "-Djava.ext.dirs=" + System.getProperty("java.ext.dirs"), className, arg1, arg2);
  logger.debug("Running as {}", new Object[]{pb.command()});
  
  pb.start();
  </code></pre>
  
  <p>The process works correctly, except in the cases where the program needs it's children to have additional memory. </p>
  
  <p>I've iterated over <code>System.getProperties()</code> to look for any of the memory settings, but none seem present.</p>
  
  <p>Specifically, the three memory configurations I need are <code>-Xms</code>, <code>-Xmx</code>, and <code>-XX:MaxPermSize</code></p>