Low memory due to leftover app_process instances

12 March 2014 by Lincoln Ramsay

I have a RAZR i with the standard UK 4.1.2 ROM. Sometimes I’ve had low memory problems or periods where the battery runs down unexpectedly. I recently started experiencing severe memory shortage every now and then. Despite my initial assumption this was related to running with data disabled, it turns out something else was the culprit. The problem came down to a large number of app_process instances hanging around, taking up 8M of RAM each.

From what I can tell, I should not see these. Android runs this process as a container to load Java code into. When this happens, the app changes its personality. So while there’s plenty of app_process instances running, they don’t show up as such when you do a ps.

I found this out the hard way running killall app_process 😕

But I can use this line to kill off any of these “zombie” app_process instances:

ps | grep app_process | busybox awk '{print $2}' | xargs kill

Root Cause Identified

I’ll spare you a full rundown of my investigative process and skip to the cause. It’s because my phone has no showmap command. Unwinding a bit, the dumpstate command tries to run this command once for every running process. It does this via su.

Somehow, doing this causes all the app_process instances to get left behind. I’m guessing some other bug is the cause of that, but without knowing exactly what happens in the dumpstate -> su -> showmap chain, I can’t be sure.

Here’s the relevant logcat snippet.

03-22 16:24:48.440 D/su      ( 6756): su invoked.
03-22 16:24:48.440 D/su      ( 6756): Allowing shell.
03-22 16:24:48.440 D/su      ( 6756): 2000 /system/xbin/su executing 0 showmap using binary showmap : showmap 129
03-22 16:24:48.440 E/su      ( 6756): exec failed with 2: No such file or directory

Triggers

How does one trigger dumpstate then?

One way it via adb bugreport. Hmm… That could be a useful command but for me, it’s now a bomb waiting to blow up my phone 🙁

The other way (and the way that was hitting me) is bug2go-bugreport. I removed the bug2go apk from my phone but there were 2 scripts in /system/bin still. One or both of these were getting called on a somewhat regular schedule.

Solution

For me, the solution was to remove the 2 bug2go scripts from /system/bin.

Leftovers

I see am starting up over and over. It seems to be a util to run an Android app from the commandline.

2014-03-20-08-45-47.txt|417225| 03-22 16:24:38.620 D/AndroidRuntime( 6140): Calling main entry com.android.commands.am.Am

I use the Koush Superuser app, which provides su. Everything else involved here should be stock.