更新时间:2023-02-02 19:31:02
你试过分析了code。与traceview?
插入
Have you tried profiling the code with traceview? insert
Debug.startMethodTracing("myfile");
在的onCreate,然后
in onCreate, then
Debug.stopMethodTracing();
您希望它完成写入文件。要查看结果,将设备插入计算机并运行:
where you want it to finish writing the file. To view the results, plug the device into the computer and run:
/path/to/android-sdk/platform-tools/adb pull /sdcard/myfile.trace
/path/to/android-sdk/tools/traceview ./myfile.trace
这将显示哪些类是花更多的时间。您可以优化慢班,和/或移动到后台线程。
This will show what classes are taking more time. You may be able to optimize the slower classes, and/or move it to a background thread.
您提到它的一些手机工作得很好,也许是那些与24MB /应用的限制,而不是16MB /程序限制较新的手机?您可以尝试在Eclipse的内存分析,检查内存泄漏或不必要的大对象。要安装,转到帮助 - >安装软件,并使用
You mentioned it works fine in some phones, perhaps those are the newer phones with 24mb/app limit instead of 16mb/app limit? You might try the Memory Analyzer in Eclipse, to check for memory leaks or unnecessary large objects. To install, go to Help -> Install Software, and use
http://download.eclipse.org/mat/1.1/update-site/
然后,当你在DDMS视图中选择转储HPROF文件(绿色玻璃用红色箭头)调试,它应该打开存储分析仪。
Then, while you are debugging in DDMS view, select Dump HPROF File (The green glass with the red arrow), it should open the memory analyzer.
编辑 -
看来你需要将Android的HPROF文件现在转换,因为这里描述。
It seems you need to convert the Android-hprof file now, as described here.