Frage

I have a running Scala process and want to get the contents of a List in that process. I know the PID of the process and I know the name of the List[String], and I have taken a heap dump with VisualVM. Is there a way for me to find the actual contents of that specific list and save it somewhere?

War es hilfreich?

Lösung

If the List[String] instance is referenced by a class (for example via a val) than you can look for the class that holds it.

  • You can download Eclipse Memory Analyzer (MAT) and open your heap dump.
  • You can then click the 'Dominator tree' and in the top of the table you can type the name of the class that holds your list.
  • If you have found the class right-click it and select 'List objects -> With Incoming References`, that should give you the instances of the class that all could potentially hold the list.
  • Right click one of the instances and select 'List objects -> With Outgoing References', that should give you a tree structure where you would find your list
  • Note that once you find your list, you can check out the panel on the left (the inspector panel), that contains readable information.

Note: the above steps are from the top of my head, so they might not be completely accurate. This should however give you a good sense of direction.

Good luck!

Andere Tipps

I'm sure in principle it is possible, but surely there's nothing simple or straightforward and off-the-shelf to allow you to do so.

I'd probably go with using the Java Platform Debugger Architecture (JPDA) and its Java Debugging Wire Protocol (JDWP) to get at the raw information you'd need. From there you can use Java and / or Scala reflection to discover what to query in the target JVM.

I don't know how much of this is applicable to heap dumps. In the old days, the C / Unix debugging tools could operate on either core dumps or active processes.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top