JAVA parameters

Document: http://docs.oracle.com/javase/6/docs/technotes/tools/windows/java.html

  1. 查看各种参数默认值:java -XX:+PrintFlagsFinal
  2. -Xmx: Specify the maximum size, in bytes, of the memory allocation pool. (MaxHeapSize)
    设置太小,程序一超过就会产生错误OOM:

    Exception in thread "main" java.lang.OutOfMemoryError: GC overhead limit exceeded
  3. -Xms: Specify the initial size, in bytes, of the memory allocation pool. (InitialHeapSize)
    设置太大,程序一运行就会产生错误:

    # There is insufficient memory for the Java Runtime Environment to continue.
    # Native memory allocation (mmap) failed to map 143165751296 bytes for committing reserved memory.# There is insufficient memory for the Java Runtime Environment to continue.
    # Native memory allocation (mmap) failed to map 143165751296 bytes for committing reserved memory.
    Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00002b1f93400000, 143165751296, 0) failed; error='Cannot allocate memory' (errno=12)
  4. foobar