如何最大限度地减少GC_FOR_ALLOC事件再度发生? [英] How to minimize GC_FOR_ALLOC occurences?

查看:5669
本文介绍了如何最大限度地减少GC_FOR_ALLOC事件再度发生?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序导致这些可怕的GC_FOR_ALLOC出现的方式多次在特定的位置(方法):

My application is causing these dreaded GC_FOR_ALLOC occur way to many times in specific locations (methods):

12-29 22:20:30.229: D/dalvikvm(10592): GC_FOR_ALLOC freed 1105K, 14% free 10933K/12615K, paused 33ms, total 34ms
12-29 22:20:30.260: D/dalvikvm(10592): GC_FOR_ALLOC freed 337K, 13% free 11055K/12615K, paused 25ms, total 26ms
12-29 22:20:30.288: D/dalvikvm(10592): GC_FOR_ALLOC freed 278K, 14% free 10951K/12615K, paused 24ms, total 24ms
12-29 22:20:30.495: D/dalvikvm(10592): GC_CONCURRENT freed 633K, 11% free 11317K/12615K, paused 16ms+3ms, total 79ms
12-29 22:20:30.495: D/dalvikvm(10592): WAIT_FOR_CONCURRENT_GC blocked 16ms
12-29 22:20:30.499: D/dalvikvm(10592): WAIT_FOR_CONCURRENT_GC blocked 15ms

很明显,我认为我做错了什么关于内存管理(是的,垃圾收集是伟大的,但仍然没有释放我从一些责任,知道什么时候和放大器;如何分配)。

It's clear to me that I am doing something wrong in regard to memory management (yes, garbage collection is great but still doesn't free me from some responsibility to know when & how to allocate).

你能推荐一个故障排除方法或技术可能导致我的code和可能的解决方案?

Can you recommend a troubleshooting approach or technique that can lead me to the offending lines of code and possible solutions?

推荐答案

的Andr​​oid DDMS,这是Eclipse的Andr​​oid开发工具的一部分,有一个可用于分析和内存分配的跟踪非常有用的工具。

Android DDMS, which is part of Android development tools in eclipse, has very useful tools that you can use for profiling and memory allocation tracking.

下面的截图重点介绍了这些工具(所有DDMS下),一些工具需要通过单击左侧面板(红色高亮显示)对应的按钮激活,然后就可以看到这些值(部分带图)右侧面板中选择要观看的标签(蓝色高亮显示)

The below screenshot highlights some of these tools (all under DDMS), some tools need to be activated by clicking the corresponding button in the left panel (highlighted in red) and then you can see the values (some with graphs) in the right panel by selecting the tab you want to watch (highlighted in Blue)

堆和分配追踪器会在你的情况非常有用。

Heap and Allocation Tracker will be very useful in your case.

这篇关于如何最大限度地减少GC_FOR_ALLOC事件再度发生?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆