简体   繁体   English

为什么在运行应用程序时,它始终在Android Logcat中始终显示GC_CONCURRENT FREED和GC_CONCURRENT ALLOCATE?

[英]Why does it always shows GC_CONCURRENT FREED and GC_CONCURRENT ALLOCATE in Android Logcat while running a app?

I would like to know that why does the below message shows up everytime while running any application. 我想知道为什么在运行任何应用程序时每次都会显示以下消息。

12-11 17:18:37.141: D/dalvikvm(3155): GC_CONCURRENT freed 485K, 9% free 6696K/7303K, paused 9ms+335ms

paused 9ms+335ms due to this pause my audio which i supposed to play is missing, because as per my code it receives audio data every 40ms so here it paused for 9ms+335ms which is 10 times data loss 由于此暂停,我paused 9ms+335ms ,我应该播放的音频丢失了,因为按照我的代码,它每40ms接收一次音频数据,因此在这里它暂停了9ms+335ms ,这是数据丢失的10 times

I know its performing some kind of Garbage Collection but my question is why does it frequently comes in the logcat. 我知道它执行某种垃圾回收,但是我的问题是为什么它经常出现在logcat中。

Thanks for any kind of help!!!!!! 感谢您的任何帮助!

Garbage Collection is used by Java to prevent you from going Out of memory by removing Objects that are no longer referenced by any class and cannot be reached from your code. Java使用垃圾回收通过删除不再由任何类引用并且无法从代码访问的对象来防止内存不足。

If you have too many of these objects, you will get GC calls alot, which may at some times affect your performance. 如果这些对象太多,则会收到很多GC调用,这有时可能会影响性能。 On the other hand, having Objects that are referenced all the time, may prevent GC from being called (memory leak) and your memory may fill up and you get an OutOfMemoryException . 另一方面,拥有始终被引用的Object可能会阻止GC的调用(内存泄漏),并且您的内存可能已满,并且您收到OutOfMemoryException

Your goal is not to eliminate GC, but reduce them as much as possible in methods that are delay sensitive and are running on the UI thread (like onDraw() , getView() , ... for eg). 您的目标不是消除GC,而是在对延迟敏感并且在UI线程上运行的方法(例如onDraw()getView()尽可能地减少它们。

That is normal behaviour for Android. 这是Android的正常行为。 The phone just does garbage collection. 电话只是进行垃圾收集。 For more information checkout the great Google I/O video on this: Google I/O 2011: Memory management for Android Apps 有关更多信息,请查看以下精彩的Google I / O视频: Google I / O 2011:Android应用程序的内存管理

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM