检查Java中的内存布局 [英] Examining memory layout in Java
问题描述
我正在尝试继承,并且出于教育目的,我想检查为各种对象分配的地址以及该对象内的字段.有没有一种工具可以让我看到JVM正在使用什么内存以及它在做什么?
I am experimenting with inheritance and for educational purposes want to examine the addresses allocated for various objects and the fields within the object. Is there a tool which will let me see what memory the JVM is using and what it is using it for.
例如,如果我有两个班级:
For example if I have two classes:
class A { int i,j; int f { ...} }
class B extends A { int c; /* more methods, overriding f and declaring new ones as well */ }
并在对象a
和b
中实例化这些类.
and instantiate these classes in objects a
and b
.
是否可以使用一个工具来分析内存使用情况,并准确查看为这些内存分配了什么内存?
Is there a tool I can use to profile the memory usage and see exactly what memory is allocated for these?
谢谢!
推荐答案
我想首先了解一下JVM在某些操作系统上的功能是很有帮助的,所以请看一下 https://softwareengineering.stackexchange.com/questions/151076/approaching- java-jvm-internals
I guess is instructive first to have an image about how function JVM over some operating system, so take a look on The Java Virtual Machine. Also, a related question is https://softwareengineering.stackexchange.com/questions/151076/approaching-java-jvm-internals
这篇关于检查Java中的内存布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!