CLM logo Development Blog by CLM

Monitoring CPU usage on Android

Wow, almost year since the last entry? Time to fix that, especially when it’s such an important day — Anodia is available in the Apple AppStore for the exactly 1024 days! :)

Today I would like to share some of our experience with CPU usage on Android. As every platform is different, there are system specific aspects that we need to take care of. We noticed that Anodia on Android is using lots of CPU power when suspended, even though we’ve done the same logic as on iOS and Windows Phone. It turns out that we faced two problems:

First was related to our usage of OpenAL. Unfortunately there is no native support for OpenAL on Android, so we used apportable openal-soft port. It uses OpenSL as a backend, but as it turned out, OpenSL thread is quite busy even when all audio sources are suspended (~25% CPU usage on Sony Xperia Tipo) . Fortunately calls to alcSuspend/alcResume in game activity onPause / onResume methods solved this issue.

Second issue was related to listening for accelerometer data. On Android it’s required to unregister all listeners when suspending an activity. Otherwise it will consume CPU even when application is not used. In our case listening to accelerometer data caused ~3% CPU usage on Sony Xperia Tipo.

And that’s all, there is one simple lesson: adb shell top -m 10 and monitor tool from sdk are quite useful when it comes to monitoring CPU usage.

No comments yet

Leave a reply