问题描述
我忙着写一个应用程序,我已经注意到,它有时会崩溃,而当它和我回到我的电脑,然后我只有堆栈跟踪。
I am busy writing an app and I have noticed 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?
感谢
推荐答案
如果你调用android.os.Debug.dumpHprofData(字符串文件名),你可以捕捉,可以用或与jHat MAT被视为一个HPROF转储。你需要捕获的异常以某种方式(无论是try / catch语句或指定自己的全局默认的异常处理程序),如果你想写入/ SD卡您将需要WRITE_EXTERNAL_STORAGE许可。
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.
另请参见<一个href="https://android-git.corp.google.com/w/?p=platform/packages/apps/Email.git;a=blob;f=src/com/android/exchange/SyncManager.java;hb=a9bc41f5ecea991d06b88ce861a412288303e9dd"相对=nofollow> Dalvik的堆纹。
这篇关于有没有办法采取程序崩溃的内存转储?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!