美文网首页Hotspot源码调试
FieldsAllocationStyle参数对对象内存布局的影

FieldsAllocationStyle参数对对象内存布局的影

作者: 过三 | 来源:发表于2017-09-19 23:07 被阅读0次

取值

hotspot-jdk7u40-b62\src\share\vm\runtime\globals.hpp
  • 类型0, 引用在原始类型前面, 然后依次是longs/doubles, ints, shorts/chars, bytes, 最后是填充字段, 以满足对其要求.
  • 类型1, 引用在原始类型后面
  • 类型2, JVM在布局时会尽量使父类对象和子对象挨在一起, 原因后面解释.

调试

代码

public class OopKlassTest {
    
    public int theInt;
    public long theLong;
    public String theString;
    
    public static void main(String[] args) {
        OopKlassTest oopKlassTest = new OopKlassTest();
        oopKlassTest.theInt = 10;
        oopKlassTest.theLong = 20;
        oopKlassTest.theString = "oopKlassTest";
        
        int x = 100;
        int y = 200;
        int z = 300;
    }
}

FieldsAllocationStyle=0

编译调试

FieldsAllocationStyle=1
同理FieldsAllocationStyle=1时,引用在原始类型后面

相关文章

网友评论

    本文标题:FieldsAllocationStyle参数对对象内存布局的影

    本文链接:https://www.haomeiwen.com/subject/auagsxtx.html