Java堆的标准分配比例 [英] Standard allocation ratio for Java heap

查看:414
本文介绍了Java堆的标准分配比例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试搜索这个问题的答案,但从未设法找到任何答案。



为Java GC分配大小的标准比率是多少当我定义一个最大堆大小?



那就是:如果我用堆的4Gb来启动我的JVM,给Eden分配多少?幸存者多少钱?

另外,不同虚拟机厂商的这个比例是否会发生变化?

预先致谢

解决方案

这是特定于JVM的。在Oracle的JVM上,您可以通过使用 -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版本1.7.0_09
Java™SE运行时环境(build 1.7.0_09-b05)
Java HotSpot™ 64位服务器虚拟机(构建23.5-b02,混合模式)

PSYoungGen总计22464K,使用770K [0x000000013e820000,0x0000000140130000,0x0000000157970000)
eden空间19264K,使用4%[0x000000013e820000, 0x000000013e8e0b08,0x000000013faf0000)
从空间3200K,使用0%[0x000000013fe10000,0x000000013fe10000,0x0000000140130000)
到空间3200K,使用0%[0x000000013faf0000,0x000000013faf0000,0x000000013fe10000)
ParOldGen总计51328K,使用0K [0x000000010c570000,0x000000010f790000,0x0 00000013e820000)
对象空间51328K,使用0%[0x000000010c570000,0x000000010c570000,0x000000010f790000)
PSPermGen总计21248K,使用2165K [0x0000000107370000,0x0000000108830000,0x000000010c570000)
对象空间21248K,使用10%[0x0000000107370000 ,0x000000010758d6a8,0x0000000108830000)

由此,您可以轻松计算比率。


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

解决方案

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.

这篇关于Java堆的标准分配比例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆