[Android Software/Hacking General [Developers Only]] pikachu01:
*rolls eyes* again.

I've already explained about how Android memory management works right?

Having the lowMemory condition isn't a bad thing when it occurs early. People actually program apps to detect lowMemory conditions to accommodate to it by either releasing memory or killing itself if it's in the background, or selectively tweaking it's self OOM so that it is harder to kill/easier to kill.

Let me define cripple as in crippling the Android memory management. Cripple in this sense means:

- The Android LMK is disabled

- Apps have no way of knowing if there is really a low memory occurence

Let me give you a chronology of events so that you can understand. (assuming that this is the lowest end phone with 256MB of RAM)

1. Supercharger tweaks the /sys/module/lowmemorykiller to an LMK value (an example would be 8,12,26,28,30,32).

2. Supercharger tweaks the Android LMK HOME_ADJ to be 1. So it, in turn gets a *_MEM of 8192KB (for example)

3. lowMemory would then be triggered when available memory is 18432MB or less. (Based on example that hiddenAppMem is 28672MB)

4. For example, you have an AngryBirds game in the background and you are surfing on your Opera Mobile on how to pass a level, then you go on Youtube to view the tutorial.

5. At this point, your Youtube is in the foreground and Opera Mobile/Angry Birds in the background, slowly increasing its OOM values from HEAVY_WEIGHT to HIDDEN_APP.

6. At this point, memory drops below 25MB and your OOM killer looks for victims to kill. EMPTY_APPs are already gone and killed and still only 25MB is available, so your OOM killer looks for more targets.

7. Opera Mobile and Angry Birds is still there happily staying the background, RAM still uncommitted, your tabs open and game half way played.

8. OOM killer sees them and kills them.

9. You switch back and see that Opera Mobile is killed and all the tabs are not saved. *sadpanda*

10. You switch back to Angry Birds and see that your half-way-played game is gone!!!! You have to replay *cries*

Here's what you see when you're not crippled

1. Android LMK tweaks the /sys/module/lowmemorykiller to be 8192, 12288, 16384, 24576, 28672, 32768MB.

2. Android LMK tweaks the Android LMK HOME_ADJ to be 6. So it, in turn gets a *_MEM of 28672KB (for example)

3. lowMemory would then be triggered when available memory is 28672KB or less. (Based on example that hiddenAppMem is 28672KB)

4. For example, you have an AngryBirds game in the background and you are surfing on your Opera Mobile on how to pass a level, then you go on Youtube to view the tutorial.

5. At this point, your Youtube is in the foreground and Opera Mobile/Angry Birds in the background, slowly increasing its OOM values from HEAVY_WEIGHT to HIDDEN_APP.

6. At this point, memory drops below 25MB and your OOM killer looks for victims to kill. EMPTY_APPs are already gone and killed and still 25MB is available, so your OOM killer looks for more targets.

7. Even before memory hits 25MB, Opera Mobile and Angry Birds already detected that it has passed the lowMemory threshold.

8. Angry Birds save it's state, discards all of the graphics data to return memory into the phone. Opera Mobile save its state of its tabs and then empties the data for all the other tabs other than the one in the foreground.

9. Free memory goes back up to 40MB and the OOM killer stops killing.

9. You switch back and see that Opera Mobile has all your tabs opened (but only the foreground tab has data, all the other tabs needs a reload)

10. You switch back to Angry Birds and see that your half-way-played game is loading and it's back!