Skip to content
Advertisement

How to print the location of Heap using java for a process?

I want to test if ASLR which randomizes the location of a heap for a process actually works.

Advertisement

Answer

You can’t do this in pure Java.

  • Machine address (pointers) are not exposed to Java applications.

  • Even if they did, there’s no Java API that tells you were the heap is.

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.

4 People found this is helpful
Advertisement