如何使用Java为进程打印堆的位置? [英] How to print the location of Heap using java for a process?
问题描述
我想测试为进程随机分配堆位置的ASLR是否有效.
I want to test if ASLR which randomizes the location of a heap for a process actually works.
推荐答案
您不能在纯Java中做到这一点.
You can't do this in pure Java.
-
机器地址(指针)未公开给Java应用程序.
Machine address (pointers) are not exposed to Java applications.
即使这样做,也没有Java API可以告诉您堆是什么.
Even if they did, there's no Java API that tells you were the heap is.
我想您可以将System.identityHashcode()
返回的值用作ersatz机器地址.如果编写了一个简单的Java测试应用程序来检查示例对象的身份哈希码,然后在启用和禁用ASLR的情况下多次运行它,则可能会发现可预测性有所不同.
I suppose that you could use the values returned by System.identityHashcode()
as ersatz machine addresses. If you wrote a simple Java test application that examined identity hashcode of a sample object, then ran it multiple times with ASLR enabled and disabled, you might observe a difference in predictability.
这篇关于如何使用Java为进程打印堆的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!