[Galaxy S III Android Development] Yank555:
Just a few thoughts on this minfree / android task killer etc. I just picked this post to reply, but I'm actually more replying to all of those questions...

----

1) What is swap ?

Memory is divided into memory blocks that apps can use. In Android one memory block has 4096 bytes. Each memory block holds also the information when it has been used for the last time.

Considering this, one single app will be using many blocks. Some of those the app will be using a lot, some it won't. Take a simple card game. When you're playing, you're not using the app's settings menu, thus not using any of the blocks that hold those parts of the app.

Swap is a process that is used in most of modern operating systems. The virtual memory management system (that's swap !) will swap out all the blocks that were not used for a certain time, this "certain time" is influenced by swappiness and a few other parameters that we can change.

The plus is that the memory blocks that have been swapped out will free up RAM to be used by other apps, thus allowing for more apps to run at the same time.

On the other hand, if you need a swapped out block, that will cost extra time, since it's not located in memory any more but on the swap partition, so it will need to be reloaded into RAM (possibly by swapping out another block to make room for this).

That should give you a glimpse on the benefits

and

the costs of using swap.

That should also give you an idea of why LMK (= Android's own Low Memory Killer) settings matter, since if almost no free ram is available, a swap in will generally cost a swap out first the the swap in !

Consider swap as a way to have only part of the apps in RAM instead of having all of it, and as such allowing for more apps to run at the same time.

BTW, it does not add RAM, you can only add RAM by actually adding physical RAM, anyone telling you otherwise is either lying or does not know what she/he's talking about ;)

2) What does Android Low Memory Killer do ?

All the apps you run are put into different categories (as a degree of importance).

Each category will have a number of memory pages (the 4Kb pages I spoke about above) limit, which as soon as free ram drops below of that limit, will make LMK start killing tasks of that category.

So the higher the limits, the sooner it will start its blood bath and kill away, or put otherwise, the higher the limit, the more free RAM you will have at

any

time.

ALMK is your guardian of free RAM.

3) Now swap & ALMK ??? How can swap work if ALMK keeps killing away ??

If you understood correctly the way those two work, you will have noticed they have two different triggers :

- LMK : number of free memory blocks per app category

- swap : time a block has not been used

So swap will be filled over time, by unused blocks of apps running for a longer period of time (widgets, background apps mostly, but not exclusively).

By filling swap, memory blocks are beeing freed, so more free RAM is available.

If more memory blocks are freed, the LMK will be triggered later, since as long as it sees enough free blocks, it's happy and will do nothing.

Hopefully this explains to everyone how this all works, and helps you understand what is what, and why some combos work and some just don't.

In essence, don't use too low LMK values, as low memory will induce lag, because it will either require app kills (which need resources) or swap out / swap in operation (which also need resources, less though).

High LMK settings will not impeed swap to work, it will be used less or it will take more uptime to be used the same, since less apps can reside in memory, but with swap and given LMK settings, you will always be able to run more apps than without swap at the same given LMK settings.

JP.

EDIT : FAQ updated with this information as I belive it is important enough to fit in there ;)