JVMパラメータ構成

6311 ワード

ヒープメモリサイズ構成これが私の初期値です
public class Test {
			public static void main(String[] args) {
				System.out.println("    "+Runtime.getRuntime().maxMemory()/1024/1024);
				System.out.println("    "+Runtime.getRuntime().freeMemory()/1024/1024);
				System.out.println("    "+Runtime.getRuntime().totalMemory()/1024/1024);
					
			}
}
    882
    58
    59

``
         ,RunAs  `
![         ](https://img-blog.csdnimg.cn/20190127134745857.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzI4NjMxOTM1,size_16,color_FFFFFF,t_70)
![         ](https://img-blog.csdnimg.cn/20190127135108396.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzI4NjMxOTM1,size_16,color_FFFFFF,t_70)
    :  -Xmx20m -Xms5m  
  :   Java         20M,      5M。

         


public class Test { public static void main(String[] args) { byte[] b = null; for (int i = 0; i < 10; i++) { b = new byte[1 * 1024 * 1024]; }//-Xms 20 m-Xmx 20 m-Xmn 1 m-XX:SurvivorRatio=2-XX:+PrintGCDetails-X:+ UseSerialGC//説明:スタックメモリ初期化値20 m、スタックメモリ最大値20 m、新生代最大値1 m、eden空間とfrom/to空間の割合2/1 System.out.println("最大メモリ"+Runtime.getRuntime().maxMemory()/1024/1024);System.out.println("使用可能メモリ"+Runtime.getRuntime().freeMemory()/1024/1024);System.out.println(「メモリ済み」+Runtime.getRuntime().totalMemory()/1024/1024);
		}

}
[GC[DefNew: 512K->256K(768K), 0.1263384 secs] 512K->439K(20224K), 0.1423776 secs] [Times: user=0.00 sys=0.00, real=0.14 secs] 
    19
    9
    19
Heap
 def new generation   total 768K, used 392K [0x00000000f9a00000, 0x00000000f9b00000, 0x00000000f9b00000)
  eden space 512K,  26% used [0x00000000f9a00000, 0x00000000f9a22320, 0x00000000f9a80000)
  from space 256K, 100% used [0x00000000f9ac0000, 0x00000000f9b00000, 0x00000000f9b00000)
  to   space 256K,   0% used [0x00000000f9a80000, 0x00000000f9a80000, 0x00000000f9ac0000)
 tenured generation   total 19456K, used 10423K [0x00000000f9b00000, 0x00000000fae00000, 0x00000000fae00000)
   the space 19456K,  53% used [0x00000000f9b00000, 0x00000000fa52dff0, 0x00000000fa52e000, 0x00000000fae00000)
 compacting perm gen  total 21248K, used 2437K [0x00000000fae00000, 0x00000000fc2c0000, 0x0000000100000000)
   the space 21248K,  11% used [0x00000000fae00000, 0x00000000fb061608, 0x00000000fb061800, 0x00000000fc2c0000)
No shared spaces configured.
        :     -XX:+PrintGCDetails -XX:+UseSerialGC


最大メモリ958使用可能メモリ49メモリ59 Heap def new generation total 19008 K,used 11254 K[0 x 00000000 bce 00000,0 x 00000000 be 2 a 00000,0 x 00000000 d 18 a 00000)eden space 16896 K,66%used[0 x 00000000 bce 00000,0 x 00000000 bd 8 fd 8,0 x 00000000 bde 80000)from space 2112 K,0%used[0x00000000bde80000, 0x00000000bde80000, 0x00000000be090000) to space 2112K, 0% used [0x00000000be090000, 0x00000000be090000, 0x00000000be2a0000) tenured generation total 42368K, used 0K [0x00000000d18a0000, 0x00000000d4200000, 0x00000000fae00000) the space 42368K, 0% used [0x00000000d18a0000, 0x00000000d18a0000, 0x00000000d18a0200, 0x00000000d4200000) compacting perm gen total 21248K, used 2437K [0x00000000fae00000, 0x00000000fc2c0000, 0x0000000100000000) the space 21248K, 11% used [0x00000000fae00000, 0x00000000fb061608, 0x00000000fb061800, 0x00000000fc2c0000) No shared spaces configured.
デフォルトの構成であるeden:from:to=8:1:1が見つかりません.新生代と旧世代の比列を構成します.
public class Test {
			public static void main(String[] args) {
				byte[] b = null;
				for (int i = 0; i < 10; i++) {
				b = new byte[1 * 1024 * 1024];
				}
				//-Xms20m -Xmx20m -XX:SurvivorRatio=2 -XX:+PrintGCDetails -XX:+UseSerialGC
				//-XX:NewRatio=2
				
				System.out.println("    "+Runtime.getRuntime().maxMemory()/1024/1024);
				System.out.println("    "+Runtime.getRuntime().freeMemory()/1024/1024);
				System.out.println("    "+Runtime.getRuntime().totalMemory()/1024/1024);
					
			}
}
[GC[DefNew: 2727K->1491K(5120K), 0.0056978 secs] 2727K->1491K(18816K), 0.0058141 secs] [Times: user=0.00 sys=0.00, real=0.01 secs] 
[GC[DefNew: 4675K->1024K(5120K), 0.0041652 secs] 4675K->1491K(18816K), 0.0042222 secs] [Times: user=0.01 sys=0.00, real=0.01 secs] 
[GC[DefNew: 4124K->1024K(5120K), 0.0143805 secs] 4591K->1491K(18816K), 0.0144341 secs] [Times: user=0.00 sys=0.00, real=0.01 secs] 
    18
    14
    18
Heap
 def new generation   total 5120K, used 3228K [0x00000000f9a00000, 0x00000000fa0a0000, 0x00000000fa0a0000)
  eden space 3456K,  63% used [0x00000000f9a00000, 0x00000000f9c27340, 0x00000000f9d60000)
  from space 1664K,  61% used [0x00000000f9f00000, 0x00000000fa000010, 0x00000000fa0a0000)
  to   space 1664K,   0% used [0x00000000f9d60000, 0x00000000f9d60000, 0x00000000f9f00000)
 tenured generation   total 13696K, used 467K [0x00000000fa0a0000, 0x00000000fae00000, 0x00000000fae00000)
   the space 13696K,   3% used [0x00000000fa0a0000, 0x00000000fa114ea8, 0x00000000fa115000, 0x00000000fae00000)
 compacting perm gen  total 21248K, used 2440K [0x00000000fae00000, 0x00000000fc2c0000, 0x0000000100000000)
   the space 21248K,  11% used [0x00000000fae00000, 0x00000000fb062128, 0x00000000fb062200, 0x00000000fc2c0000)
No shared spaces configured.

次は私のデフォルトです
    958
    59
    59
Heap
 def new generation   total 19008K, used 1014K [0x00000000bce00000, 0x00000000be2a0000, 0x00000000d18a0000)
  eden space 16896K,   6% used [0x00000000bce00000, 0x00000000bcefd838, 0x00000000bde80000)
  from space 2112K,   0% used [0x00000000bde80000, 0x00000000bde80000, 0x00000000be090000)
  to   space 2112K,   0% used [0x00000000be090000, 0x00000000be090000, 0x00000000be2a0000)
 tenured generation   total 42368K, used 0K [0x00000000d18a0000, 0x00000000d4200000, 0x00000000fae00000)
   the space 42368K,   0% used [0x00000000d18a0000, 0x00000000d18a0000, 0x00000000d18a0200, 0x00000000d4200000)
 compacting perm gen  total 21248K, used 2437K [0x00000000fae00000, 0x00000000fc2c0000, 0x0000000100000000)
   the space 21248K,  11% used [0x00000000fae00000, 0x00000000fb061578, 0x00000000fb061600, 0x00000000fc2c0000)
No shared spaces configured.
                   1:2。

後は更新と勉強中