I would like to be able to trigger an Android heap dump from the command line. Is there a command for that?
Specifically, from the command line, not via Montior or DDMS GUIs
Maybe something like using ddms or adb, e.g. ddms -head-dump
or adb shell heapdump
? AFAICT monitor and ddms always start in GUI mode, and adb doesn't have a heap dump command.
Update: I tried this, it looked promising, but it doesn't work:
adb jdwp
adb forward tcp:8000 jdwp:1234
(substitute output of 1 for 1234)jmap -dump:format=b,file=heapdump.hprof localhost:8000
But even the heap summary fails:
jmap -heap localhost:8000
Attaching to remote server localhost:8000, please wait...
Error attaching to remote server: java.rmi.ConnectIOException: error during JRMP connection establishment; nested exception is:
java.net.SocketTimeoutException: Read timed out