<legend id='72HiG'><style id='72HiG'><dir id='72HiG'><q id='72HiG'></q></dir></style></legend>

    <tfoot id='72HiG'></tfoot>
  1. <i id='72HiG'><tr id='72HiG'><dt id='72HiG'><q id='72HiG'><span id='72HiG'><b id='72HiG'><form id='72HiG'><ins id='72HiG'></ins><ul id='72HiG'></ul><sub id='72HiG'></sub></form><legend id='72HiG'></legend><bdo id='72HiG'><pre id='72HiG'><center id='72HiG'></center></pre></bdo></b><th id='72HiG'></th></span></q></dt></tr></i><div id='72HiG'><tfoot id='72HiG'></tfoot><dl id='72HiG'><fieldset id='72HiG'></fieldset></dl></div>
  2. <small id='72HiG'></small><noframes id='72HiG'>

      <bdo id='72HiG'></bdo><ul id='72HiG'></ul>

    1. Java中为一个Integer对象分配多少内存?如何找出任何自定义对象的这个值?

      时间:2023-08-23

        • <bdo id='dRCzF'></bdo><ul id='dRCzF'></ul>
        • <small id='dRCzF'></small><noframes id='dRCzF'>

          <tfoot id='dRCzF'></tfoot>

              <i id='dRCzF'><tr id='dRCzF'><dt id='dRCzF'><q id='dRCzF'><span id='dRCzF'><b id='dRCzF'><form id='dRCzF'><ins id='dRCzF'></ins><ul id='dRCzF'></ul><sub id='dRCzF'></sub></form><legend id='dRCzF'></legend><bdo id='dRCzF'><pre id='dRCzF'><center id='dRCzF'></center></pre></bdo></b><th id='dRCzF'></th></span></q></dt></tr></i><div id='dRCzF'><tfoot id='dRCzF'></tfoot><dl id='dRCzF'><fieldset id='dRCzF'></fieldset></dl></div>
                <tbody id='dRCzF'></tbody>
                <legend id='dRCzF'><style id='dRCzF'><dir id='dRCzF'><q id='dRCzF'></q></dir></style></legend>
              • 本文介绍了Java中为一个Integer对象分配多少内存?如何找出任何自定义对象的这个值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                衡量应该使用堆中多少内存来创建特定类型的新对象的正确方法是什么(让我们谈谈整数以保持简单)?

                What is the proper way to measure how much memory from the heap should be used to create new object of a certain type (let's talk about Integers to keep it simple)?

                这个值可以不用实验计算出来吗?这种情况下的规则是什么?这些规则是否在某处严格指定,或者它们可能因 jvm 而异?

                Can this value be calculated without experiment? What are the rules in that case? Are these rules strictly specified somewhere or they can vary from jvm to jvm?

                推荐答案

                它可能因JVM而异.

                您可能会喜欢 Oracle 工程师的这篇博文:

                You may like this blog post from an Oracle engineer:

                对于 32 位 Hotspot JVM 上的 Java Integer,32 位有效负载(Integer.value 字段)伴随着 96 个附加位、一个标记、一个 klass 和一个对齐填充字,总共 128 位.此外,如果世界上有(比如说)六个对该整数的引用(线程加堆),那么这些引用也占用 192 位,总共 320 位.在 64 位机器上,一切都大了一倍,至少目前是这样:对象中有 256 位(现在包括 96 位填充),其他地方有 384 位.相比之下,一个未装箱的原始整数的六个副本占用 192 位

                In the case of a Java Integer on a 32-bit Hotspot JVM, the 32-bit payload (a Integer.value field) is accompanied by a 96 additional bits, a mark, a klass, and a word of alignment padding, for a total of 128 bits. Moreover, if there are (say) six references to this integer in the world (threads plus heap), those references also occupy 192 bits, for a total of 320 bits. On a 64-bit machine, everything is twice as big, at least at present: 256 bits in the object (which now includes 96 bits of padding), and 384 bits elsewhere. By contrast, six copies of an unboxed primitive integer occupy 192 bits

                这篇关于Java中为一个Integer对象分配多少内存?如何找出任何自定义对象的这个值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:如何检测String.substring是否复制了字符数据 下一篇:使用 Sigar API 获取 JVM CPU 使用率

                相关文章

                  • <bdo id='lWBDU'></bdo><ul id='lWBDU'></ul>
                  <i id='lWBDU'><tr id='lWBDU'><dt id='lWBDU'><q id='lWBDU'><span id='lWBDU'><b id='lWBDU'><form id='lWBDU'><ins id='lWBDU'></ins><ul id='lWBDU'></ul><sub id='lWBDU'></sub></form><legend id='lWBDU'></legend><bdo id='lWBDU'><pre id='lWBDU'><center id='lWBDU'></center></pre></bdo></b><th id='lWBDU'></th></span></q></dt></tr></i><div id='lWBDU'><tfoot id='lWBDU'></tfoot><dl id='lWBDU'><fieldset id='lWBDU'></fieldset></dl></div>
                1. <small id='lWBDU'></small><noframes id='lWBDU'>

                  <tfoot id='lWBDU'></tfoot>

                2. <legend id='lWBDU'><style id='lWBDU'><dir id='lWBDU'><q id='lWBDU'></q></dir></style></legend>