3

When android application (JNI+Java) goes to background, then based on Elixir monitor it takes 40-80% CPU without any visible reason. Logcat has no indication of any real activity, DDMS method profiler does not find any method calls.

In fact, after some minutes OS (ISC) at least sometimes seems to fix it automatically: restarts application process, and then it is as expected - taking 0% of CPU and some memory. When I start app again, and press home to take it to background, same CPU hogging happens.

Any ideas what could be investigated?

JaakL
  • 4,107
  • 5
  • 24
  • 37
  • Provide your code that is causing this issue. – Ali Imran Dec 01 '12 at 20:46
  • Well, investigate your code if your process uses all the cpus. Put log output everywhere or use a debugger. Invisible does not mean that threads are magically stopped. You just get no more `onSomeUiEvent` calls in your Activities. Services, broadcast-receiver & content-provider also continue. – zapl Dec 01 '12 at 21:05
  • My problem is to find the code causing the issue. It is a non-trivial project with services, receivers, a lot of code in NDK/C++ etc. I'm surprised that method profiler does not show any events while process viewer shows it. Maybe because this is the NDK side? – JaakL Dec 01 '12 at 21:17
  • Profiler won't show much about the NDK part since it's basically a Java profiler. `printf` or via [gdb](http://mhandroid.wordpress.com/2011/01/25/how-cc-debugging-works-on-android/) – zapl Dec 01 '12 at 23:34
  • 1
    So my conclusion is: 1. if the method calls are not shown in Profiler, then very probably it means that CPU is wasted in NDK side, 2. GDB-based profiling should be used there, probably something like http://stackoverflow.com/questions/6490479/android-ndk-load-cpu etc – JaakL Dec 03 '12 at 06:39

1 Answers1

1

So my conclusion is: 1. if the method calls are not shown in Profiler, then very probably it means that CPU is wasted in NDK side, 2. GDB-based profiling should be used there, probably something like that

Community
  • 1
  • 1
JaakL
  • 4,107
  • 5
  • 24
  • 37