开发者

Is there a way to take a memory dump on app crash?

开发者 https://www.devze.com 2023-01-18 13:32 出处:网络
I am busy writing an app and I have 开发者_如何学Gonoticed that it sometimes crashes, and when it does and I get back to my computer then I only have the stack trace.

I am busy writing an app and I have 开发者_如何学Gonoticed that it sometimes crashes, and when it does and I get back to my computer then I only have the stack trace.

Is there a way for me to take a memory dump of the app at crash time?

Thanks


If you call android.os.Debug.dumpHprofData(String fileName), you can capture an HPROF dump that can be viewed with jhat or MAT. You'll need to trap the exception somehow (either try/catch or specify your own global default exception handler), and if you want to write to /sdcard you'll need the WRITE_EXTERNAL_STORAGE permission.

See also Dalvik Heap Profiling.


Not a memory dump but ACRA, http://code.google.com/p/acra/, (Application Crash Report for Android) is pretty good at recording info about what's going on. With the most detailed info being a stack trace.

The debugging info on it's own might not be super helpful, but you could modify their code to do and send a logcat when your application crashes so you would get some more details about what's going on. I think they don't do this by default for privacy/security reasons but it's a bit more useful to see the logcat around the crash.

Other than that you'd need to debug it with the debugger.


Is there a way for me to take a memory dump of the app at crash time?

Not that I am aware of -- sorry!

0

精彩评论

暂无评论...
验证码 换一张
取 消