Standard allocation ratio for Java heap

微笑、不失礼 提交于 2019-12-07 07:19:12

问题


I've tried to search for an answer to this question, but never managed to find any.

What is the standard ratio for allocating size to the Java GC spaces when I define a maximum heap size?

That is: if I start my JVM with, say 4Gb of heap, how much is allocated to the Eden? How much to survivors? How much to tenured?

Also, does that ratio change for different VM vendors?

Thanks in advance


回答1:


This is JVM-specific. On Oracle's JVMs, you can find out the heap sizes by using -XX:+PrintCommandLineFlags -XX:+PrintGCDetails:

$ java -XX:+PrintCommandLineFlags -XX:+PrintGCDetails -version
-XX:InitialHeapSize=78820288 -XX:MaxHeapSize=1261124608 -XX:+PrintCommandLineFlags -XX:+PrintGCDetails -XX:+UseCompressedOops -XX:+UseParallelGC 
java version "1.7.0_09"
Java(TM) SE Runtime Environment (build 1.7.0_09-b05)
Java HotSpot(TM) 64-Bit Server VM (build 23.5-b02, mixed mode)
Heap
 PSYoungGen      total 22464K, used 770K [0x000000013e820000, 0x0000000140130000, 0x0000000157970000)
  eden space 19264K, 4% used [0x000000013e820000,0x000000013e8e0b08,0x000000013faf0000)
  from space 3200K, 0% used [0x000000013fe10000,0x000000013fe10000,0x0000000140130000)
  to   space 3200K, 0% used [0x000000013faf0000,0x000000013faf0000,0x000000013fe10000)
 ParOldGen       total 51328K, used 0K [0x000000010c570000, 0x000000010f790000, 0x000000013e820000)
  object space 51328K, 0% used [0x000000010c570000,0x000000010c570000,0x000000010f790000)
 PSPermGen       total 21248K, used 2165K [0x0000000107370000, 0x0000000108830000, 0x000000010c570000)
  object space 21248K, 10% used [0x0000000107370000,0x000000010758d6a8,0x0000000108830000)

From this, you can easily work out the ratios.



来源:https://stackoverflow.com/questions/15413783/standard-allocation-ratio-for-java-heap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!