据说,Gingerbread之前, Android GC采用stop-the-world的方式来做垃圾收集,花费时间在100ms左右,而在Gingerbread及之后,GC采用concurrent的方式来做垃圾收集,花费时间较短,在10ms左右。下面是GC 的log,可以看出,确实是用了concurrent的垃圾收集方式。
dalvikvm: GC_CONCURRENT freed 388K, 8% free 6551K/7111K, paused 19ms+2ms, total 45ms
dalvikvm: GC_CONCURRENT freed 137K, 5% free 6949K/7239K, paused 20ms+3ms, total 53ms
dalvikvm: WAIT_FOR_CONCURRENT_GC blocked 15ms
dalvikvm: GC_CONCURRENT freed 276K, 6% free 7184K/7623K, paused 17ms+2ms, total 46ms
dalvikvm: WAIT_FOR_CONCURRENT_GC blocked 13ms
dalvikvm: GC_FOR_ALLOC freed 120K, 6% free 7311K/7751K, paused 21ms, total 21ms
dalvikvm: GC_CONCURRENT freed 381K, 9% free 7367K/8007K, paused 13ms+1ms, total 36ms
dalvikvm: WAIT_FOR_CONCURRENT_GC blocked 22ms
dalvikvm: GC_FOR_ALLOC freed 117K, 7% free 7487K/8007K, paused 23ms, total 24ms
dalvikvm: GC_CONCURRENT freed 614K, 10% free 8030K/8903K, paused 25ms+4ms, total 59ms
dalvikvm: GC_CONCURRENT freed 430K, 7% free 8315K/8903K, paused 18ms+14ms, total 78ms
dalvikvm: WAIT_FOR_CONCURRENT_GC blocked 2ms
dalvikvm: GC_CONCURRENT freed 185K, 4% free 8954K/9287K, paused 14ms+3ms, total 70ms
dalvikvm: WAIT_FOR_CONCURRENT_GC blocked 18ms