Java内存参数设置笔记

通过如下命令可以查看当前版本Java的内存参数

 

java -X

 

  • -Xmixed mixed mode execution (default)
  • -Xint interpreted mode execution only
  • -Xbootclasspath:<directories and zip/jar files separated by :>
  • set search path for bootstrap classes and resources
  • -Xbootclasspath/a:<directories and zip/jar files separated by :>
  • append to end of bootstrap class path
  • -Xbootclasspath/p:<directories and zip/jar files separated by :>
  • prepend in front of bootstrap class path
  • -Xnoclassgc disable class garbage collection
  • -Xincgc enable incremental garbage collection
  • -Xloggc:<file> log GC status to a file with time stamps
  • -Xbatch disable background compilation
  • -Xms<size> set initial Java heap size
  • -Xmx<size> set maximum Java heap size
  • -Xss<size> set java thread stack size
  • -Xprof output cpu profiling data
  • -Xfuture enable strictest checks, anticipating future default
  • -Xrs reduce use of OS signals by Java/VM (see documentation)
  • -Xcheck:jni perform additional checks for JNI functions
  • -Xshare:off do not attempt to use shared class data
  • -Xshare:auto use shared class data if possible (default)
  • -Xshare:on require using shared class data, otherwise fail.

-Xms : init heap size ,可以使用 mg作为单位。正确配置,-Xms64m -Xms2g
-Xmx : max heap size ,可以使用 mg作为单位。正确配置:-Xmx64m -Xmx2g
注意:如果以g为单位,值必须为整数, “-Xmx0.5g” 是错误的配置


-XX:+PrintHeapAtGC

{Heap before GC invocations=1 (full 0):
 def new generation   total 4928K, used 4589K [0x236b0000, 0x23c00000, 0x28c00000)
  eden space 4416K, 100% used [0x236b0000, 0x23b00000, 0x23b00000)
  from space 512K,  33% used [0x23b80000, 0x23bab490, 0x23c00000)
  to   space 512K,   0% used [0x23b00000, 0x23b00000, 0x23b80000)
 tenured generation   total 10944K, used 0K [0x28c00000, 0x296b0000, 0x336b0000)
   the space 10944K,   0% used [0x28c00000, 0x28c00000, 0x28c00200, 0x296b0000)
 compacting perm gen  total 12288K, used 367K [0x336b0000, 0x342b0000, 0x376b0000)
   the space 12288K,   2% used [0x336b0000, 0x3370bf60, 0x3370c000, 0x342b0000)
    ro space 10240K,  51% used [0x376b0000, 0x37bd7b58, 0x37bd7c00, 0x380b0000)
    rw space 12288K,  54% used [0x380b0000, 0x38744ce0, 0x38744e00, 0x38cb0000)
0.071: [GC 4589K->172K(15872K), 0.0004379 secs]
Heap after GC invocations=2 (full 0):
 def new generation   total 4928K, used 172K [0x236b0000, 0x23c00000, 0x28c00000)
  eden space 4416K,   0% used [0x236b0000, 0x236b0000, 0x23b00000)
  from space 512K,  33% used [0x23b00000, 0x23b2b3d0, 0x23b80000)
  to   space 512K,   0% used [0x23b80000, 0x23b80000, 0x23c00000)
 tenured generation   total 10944K, used 0K [0x28c00000, 0x296b0000, 0x336b0000)
   the space 10944K,   0% used [0x28c00000, 0x28c00000, 0x28c00200, 0x296b0000)
 compacting perm gen  total 12288K, used 367K [0x336b0000, 0x342b0000, 0x376b0000)
   the space 12288K,   2% used [0x336b0000, 0x3370bf60, 0x3370c000, 0x342b0000)
    ro space 10240K,  51% used [0x376b0000, 0x37bd7b58, 0x37bd7c00, 0x380b0000)
    rw space 12288K,  54% used [0x380b0000, 0x38744ce0, 0x38744e00, 0x38cb0000)
}
 
-XX:+PrintGCDetails

3.800: [GC 3.800: [DefNew: 4416K->0K(4928K), 0.0000824 secs] 4589K->173K(15872K), 0.0001107 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 
3.803: [GC 3.803: [DefNew: 4416K->0K(4928K), 0.0000818 secs] 4589K->173K(15872K), 0.0001139 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 
3.806: [GC 3.806: [DefNew: 4416K->0K(4928K), 0.0000834 secs] 4589K->173K(15872K), 0.0001190 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 
3.809: [GC 3.809: [DefNew: 4416K->0K(4928K), 0.0000828 secs] 4589K->173K(15872K), 0.0001187 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 
3.812: [GC 3.812: [DefNew: 4416K->0K(4928K), 0.0000799 secs] 4589K->173K(15872K), 0.0001145 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 
 

-Xloggc:c:/gc.log


参考:
http://www.devdaily.com/blog/post/java/java-xmx-xms-memory-heap-size-control

-- heipark



 

你可能感兴趣的:(java内存)