简体   繁体   中英

Android Garbage Collector Metronome App

I have a metronome app and whenever the gc starts its is delayed for 50ms on my Nexus4, although this almost isn't noticeable I guess it's worse on older devices and some people even notice the 50ms delay. I THINK that I have optimized the code pretty well, the gc only kicks in every 5 - 10 seconds. Could someone suggest a way to 'fix' this ? Do threads written with the NDK get paused by the gc, too?

If possible, remove those remaining allocations. You won't have to stop to collect garbage if there's none to collect. The DDMS/ADT Allocation Tracker feature can help you track them down. (Note it is available in the ADT Eclipse plugin now.)

Pure-native threads are not paused by the GC, though they can still fight with the GC for the CPU. If the thread calls back into the VM, though, it will pause if a GC is in progress.

如果你在一个单独的线程上处理声音(即使它是一个Java线程),其中0分配发生,那么在另一个线程上启动的GC将不会延迟它。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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