4

I want to see the stack frame of a method from a heapdump using mat. But I can't see any primitive type in the callstack, but types like String can be displayed from the threadDetail.

public  int fun(int x, int y) {
    int d = this.hashCode();
    int a = x + y;
    String jj = "123";
    sleep(100000L); 
    return a +  d + jj.length();
}

I can only see the object instance and String jj in the stackframe. I want to know if it's the problem of MAT, or the heapdump doesn't contain primitive type variables.

enter image description here

Xinli Niu
  • 471
  • 1
  • 4
  • 6
  • Is this a PHD portable heap dump or a HPROF binary heap dump? – flakes Nov 23 '18 at 06:17
  • hprof dump, I dump it with visualvm – Xinli Niu Nov 23 '18 at 06:35
  • Well, it’s called *heap* dump, not stack dump. The heap dump allows to identify stack frames as an object’s GC root, but that’s a different feature than storing the contents of stack frames. For the included objects (heap data), the field values of primitive types are available. – Holger Nov 23 '18 at 08:34
  • is there a way to get something like 'stack dump' from a running jvm so I can't see all the local variables? – Xinli Niu Nov 24 '18 at 05:31
  • I don’t know of any. Though, there are debuggers and debuggers are just software using the JVM’s debug interface. So, in principle, it is possible to write such software reading all these values via that interface and storing them. But I don’t know of any standard (or common) tool (besides the interactive debuggers). – Holger Nov 29 '18 at 18:09
  • _is there a way to get something like 'stack dump' from a running jvm so I can't see all the local variables?_ -- in JDK9+ `jhsdb (hsdb|clhsdb)`. Works against a working JVM or a core dump (obtained with gdb/gcore). Was not very stable when I was experimenting with it: some thread stacks wouldn't be "parsed" though some would. – starikoff Dec 09 '18 at 10:55
  • ...forgot to mention: as with all `jhsdb` tools, this one freezes the process for the duration of the command (for an interactive sub-command like `hsdb` -- until you close it, usually meaning minutes/tens of minutes) – starikoff Dec 09 '18 at 11:25

0 Answers0