Reputation: 3183
I'm getting started on Android game development and one of the libraries I'm using is the universal-tween-engine. The author made some design decisions that were heavily based on performance optimizations, to the point that some aspects of the API sacrifice usability.
I was considering forking the project to a GitHub repo and cleaning up the API but I don't know the ins-and-outs of Android performance. On a standard Hotspot based JVM I wouldn't worry too much about the overhead of object instantiation and garbage collection because that platform has optimized those things enough that I'd consider the pooling behavior of this library a premature optimization but for Android I have no idea....
Compared to Hotspot what are the performance characteristics of object creation and garbage collection on Android (Gingerbread->KitKat)? If I will repeatedly create new instances of the same class (but with different state) is it worth pooling those instances?
Upvotes: 1
Views: 315
Reputation:
Unlike desktop Java apps, Android apps currently run on top of the Dalvik virtual machine.
Garbage collection is relatively expensive on mobile devices, you would want to avoid object allocation in performance sensitive code paths, it's not uncommon for garbage collection to pause your app for hundreds of milliseconds - the last thing you want for any game or when the user is scrolling through your list view.
This of course also varies depending on the device, Android limits the amount of memory an app can use, on higher end devices, in addition to the performance gain from the hardware, your app will usually be allow to use more memory, than if it was running on a lower end device.
Mobile devices have come a long way, but you still can't ignore memory management on mobile devices, even with high end devices.
I suggest you get a better understanding of performance/memory on Android (and mobile device in general) first, so when you do make performance changes to that library, you are certain that you are making an improvement (and always measure!). A good place to start is the official Best Practices for Performace.
Upvotes: 2