我喜欢垃圾收集器,它确实很好用。但问题是我的活动中有太多的对象,因为有太多的Hashmaps和arraylists以及其他对象。所以当我切换到其他活动时会发生这种情况。
12-04 01:02:17.119: D/dalvikvm(1124): GC_CONCURRENT freed 0K, 46% free 26267K/48327K, paused 2ms+5ms
12-04 01:02:17.249: D/dalvikvm(1124): GC_CONCURRENT freed 8877K, 60% free 19436K/48327K, paused 2ms+5ms
12-04 01:02:17.359: D/dalvikvm(1124): GC_CONCURRENT freed 1593K, 59% free 19888K/48327K, paused 2ms+5ms
12-04 01:02:17.459: D/dalvikvm(1124): GC_CONCURRENT freed 1572K, 58% free 20363K/48327K, paused 2ms+5ms
12-04 01:02:17.559: D/ExchangeService(578): Received deviceId from Email app: null
12-04 01:02:17.559: D/ExchangeService(578): !!! deviceId unknown; stopping self and retrying
12-04 01:02:17.569: D/dalvikvm(1124): GC_CONCURRENT freed 1594K, 57% free 20816K/48327K, paused 2ms+6ms
12-04 01:02:17.679: D/dalvikvm(1124): GC_CONCURRENT freed 1582K, 56% free 21278K/48327K, paused 2ms+5ms
12-04 01:02:17.779: D/dalvikvm(1124): GC_CONCURRENT freed 1582K, 56% free 21741K/48327K, paused 2ms+5ms
12-04 01:02:17.889: D/dalvikvm(1124): GC_CONCURRENT freed 1582K, 55% free 22203K/48327K, paused 2ms+5ms
12-04 01:02:17.999: D/dalvikvm(1124): GC_CONCURRENT freed 1579K, 54% free 22669K/48327K, paused 2ms+6ms
12-04 01:02:18.109: D/dalvikvm(1124): GC_CONCURRENT freed 1585K, 53% free 23130K/48327K, paused 2ms+6ms
12-04 01:02:18.229: D/dalvikvm(1124): GC_CONCURRENT freed 1580K, 52% free 23592K/48327K, paused 2ms+6ms
12-04 01:02:18.339: D/dalvikvm(1124): GC_CONCURRENT freed 1584K, 51% free 24052K/48327K, paused 2ms+5ms
12-04 01:02:18.449: D/dalvikvm(1124): GC_CONCURRENT freed 1570K, 50% free 24527K/48327K, paused 2ms+5ms
12-04 01:02:18.569: D/dalvikvm(1124): GC_CONCURRENT freed 1563K, 49% free 25012K/48327K, paused 2ms+6ms
12-04 01:02:18.649: D/dalvikvm(1124): GC_FOR_ALLOC freed 623K, 48% free 25189K/48327K, paused 39ms
12-04 01:02:18.659: I/dalvikvm-heap(1124): Grow heap (frag case) to 29.909MB for 5510676-byte allocation
12-04 01:02:18.719: D/dalvikvm(1124): GC_CONCURRENT freed 0K, 37% free 30571K/48327K, paused 2ms+5ms
12-04 01:02:19.159: D/dalvikvm(1124): GC_CONCURRENT freed 1976K, 37% free 30571K/48327K, paused 2ms+5ms
12-04 01:02:19.599: D/dalvikvm(1124): GC_CONCURRENT freed 1972K, 37% free 30571K/48327K, paused 2ms+5ms
12-04 01:02:20.049: D/dalvikvm(1124): GC_CONCURRENT freed 1976K, 37% free 30571K/48327K, paused 2ms+6ms
所以问题是切换到其他活动暂停应用程序4到5秒,看起来该应用程序将执行不幸然后开始运行。 那么我该怎么做才能暂停应用程序的活动
我试过了什么
1.在异步任务中启动活动。 (当GC完成上述工作时显示进度条)
但进度对话框也会暂停
2.对处理程序和线程执行相同的操作。