OpenJDK源代码内部如何解释在何处分配堆内存? [英] How and where does allocating a heap memory interpreted inside OpenJDK source code?

查看:479
本文介绍了OpenJDK源代码内部如何解释在何处分配堆内存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为我的研究项目更改OpenJDK的源代码.我想在Java程序中调用新运算符时知道代码流.

I'm trying to alter OpenJDK source for my research project. I want to know the code flow when I invoke a new operator inside a Java program.

class MyFirstProgram {
    public static void main(String args[]) throws Exception{
        System.out.println("Hello World!");
        int i[] = new int[50];
    }
}

在OpenJDK源代码中,我在新的操作员实现中放入了一些打印件. (路径: OpenJDKDev/src/hotspot/share/memory/allocation.cpp )

In the OpenJDK source code, I put several prints inside new operator implementation. (Path: OpenJDKDev/src/hotspot/share/memory/allocation.cpp)

我不确定是否要检查正确的文件以进行内存分配. 看起来,即使我调用java -version,它也会打印出我多次输入的消息.

I'm not sure if I'm checking the right file for memory allocation. It seems like even when I call java -version, it prints the messages I put many times.

当我在用户Java程序中调用新的内存时,我找不到执行内存分配调用的准确程度(以及确切位置).

I'm not able to find how exactly (and where exactly) the memory allocation calls are made when I call a new inside a user Java program.

->使用JDK11.

--> Using JDK11.

推荐答案

我对您有个坏消息. HotSpot源代码中没有一个地方可以处理所有Java分配.

I have a bad news for you. There is no a single place in HotSpot sources that handles all Java allocations.

可能会发生分配:

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