Java程序的程序计数器寄存器值 [英] Program Counter register values for a Java program

查看:55
本文介绍了Java程序的程序计数器寄存器值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以获取正在运行的Java应用程序的程序计数器(PC)寄存器值,尤其是在Android模拟器中运行的Java应用程序?例如,gprof随机采样PC寄存器值,以找出哪个功能正在消耗程序的运行时间.这样的概念对于JVM甚至有意义吗?为了澄清,我想要程序计数器的实际值.

Is it possible to obtain the program counter (PC) register values of a running Java application, particularly one running in an Android emulator? gprof, for example, randomly samples PC register values in order to find which function is consuming the running time of the program. Does such a concept even make sense with the JVM? To clarify, I would like actual values of the program counter.

还有,我有什么方法可以衡量代码在内存中的扩散程度?通过查看objdump返回的地址范围,可以在常规程序中对此进行某种程度的测量.但是,这种方法不能处理共享库的地址,这也是我在JVM上下文中不了解的概念.

Also, is there some way I can measure how "spread out" the code is in memory? This can somewhat be measured in a regular program by looking at the range of addresses returned by objdump. However, this approach does not handle address of shared libraries, which again is a concept I don't understand in the context of the JVM.

推荐答案

许多Java分析器,例如 VisualVM 基于采样的性能分析,可能像您描述的那样工作.

Many Java profilers like VisualVM can do sampling-based profiling, which probably works like you describe.

关于代码内存的使用,这就是垃圾收集器的永久生成"(PermGen)主要包含的内容;VisualVM也可以显示它.

As for code memory usage, this is what the "permanent generation" (PermGen) of the garbage collector mainly contains; VisualVM can display that as well.

这篇关于Java程序的程序计数器寄存器值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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