3 ms·
Garbage collection in Android is another performance bottleneck. ICS "fixes" this by allowing the garbage collector to run on a different thread but imo that's
by beatle 15y ago
Garbage collection in Android is another performance bottleneck. ICS "fixes" this by allowing the garbage collector to run on a different thread but imo that's
a kludge.
- babebridou 15y agoYou're beating a dead horse alright, but it's the wrong one. Garbage collection has never had anything to do with poor UI performances, and everything to do with making poor code stutter. When the GC starts hitting your framerate, it means you are creating far too many objects and far too frequently. Before ICS, android implemented the incremental GC that runs more often but for "negligible" sub-1ms lengths. If you absolutely need 60fps, make sure the GC never gets to do any work and start monitoring your own memory through buffers, just like you would in any other language.
- beatle 15y agoUsers don't distinguish between poor UI performance and"code stutters". The "negligble" sub-1ms stutters are a real problem in practice. and it's not just limited to poor code. Sometimes, no matter what you'll see GC being called, there's no way around it. There are background threads that are doing all sorts of things, which very well might be getting GC'd. Theres also a lot of things you can't reasonably avoid, like allocations from Iterators, etc. There are literally thousands of forum and blog posts discussing this online. Garbage Collection very slow on Android with latest stable line http://groups.google.com/group/v8-users/browse_thread/thread/bd3a269ff4107619 http://groups.google.com/group/v8-users/browse_thread/thread... How can I avoid garbage collection delays in Java games http://stackoverflow.com/questions/2484079/how-can-i-avoid-garbage-collection-delays-in-java-games-best-practices http://stackoverflow.com/questions/2484079/how-can-i-avoid-g... Avoiding garbage collection for smooth 2d animations Options http://groups.google.com/group/android-developers/browse_thread/thread/e342700f10e9f830 http://groups.google.com/group/android-developers/browse_thr... Image tiling on Android, garbage collector slows down http://stackoverflow.com/questions/7916021/image-tiling-on-android-garbage-collector-slows-down http://stackoverflow.com/questions/7916021/image-tiling-on-a...
- babebridou 15y agoPoor choice of words on my part. It's not "poor code" but "inadequate code". The Android graphics API is, overall, inadequate for avoiding GCs at all costs. Java on the other hand, is not necessarily inadequate. The issues with GC and the Bitmap class are a good example: Bitmaps aren't designed to work at the lowest & fastest level but at the highest and easiest level. Nothing beats primitives and buffers - the performance gap between the two methods is huge, that's true, but it's not a showstopper. I don't recall gcs in other processes hurting my apps performances though. With that said, if I'm going to write a game, I'll make sure none of the threads in my process will trigger a GC past the loading/splash screen. This means no instanciations of any additional iterators, collections, Strings... The overhead of allocations is almost as bad for the framerate as the GC anyway.