[Android Software/Hacking General [Developers Only]] zeppelinrox:
MFK Calculator Info (vm.min_free_kbytes)

Here is a repost from another thread. I'll be adding the MFK calculation to KAK.

Because of you I'm making MFK a calculated value...

Ass... lol

It will be a percentage/fraction of Secondary Sever's LMK value...

Why? Because its a balancing act of cached ram (speed) vs reserved ram (MFK for individual apps to share)

ie. Free RAM (reported by android) = ram used to cache data + idle ram (minimun is the MFK value)

For example, on my 256 mb device, android says I have 30mb free (as per my minfree settings)

But the free command in terminal or my engine flush script shows 4 or 5 mb free.

This is because the free command considers ram used for cached data to be used so it only reports the idle ram (some say its wasted lol)

However, I think that the idle ram is the ram shared by open apps (which is what MFK effects)

I think this because if I make MFK 2mb, then the free command shows I only have 2mb free.

If I change it to 8, then free shows 8mb to be free or idle.

There is a direct connection.

Do this : cat /proc/meminfo

Memfree is what the free command reports.

Android reports MemFree + Cached to be free ram.

So what's my point... well... if I have a reported 30 mb free and the free command shows I have 5mb free, this means I have 25mb cached - which is what makes things snappy :)

But if I make MFK 20mb, then I will only have about 5 mb available for cache...which would slow things down.

So... gotta play the percentages...

And because the Secondary Server LMK value has the most effect on typical free ram, I will use a percentage of that...

Take this calculator for a ride...

#!/system/bin/sh
# vm.min_free_kbytes calculator created by zeppelinrox.
#
SS=`getprop ro.SECONDARY_SERVER_ADJ`
minfree1=`awk -F , '{print $1}' /sys/module/lowmemorykiller/parameters/minfree`;minfree2=`awk -F , '{print $2}' /sys/module/lowmemorykiller/parameters/minfree`;minfree3=`awk -F , '{print $3}' /sys/module/lowmemorykiller/parameters/minfree`;minfree4=`awk -F , '{print $4}' /sys/module/lowmemorykiller/parameters/minfree`;minfree5=`awk -F , '{print $5}' /sys/module/lowmemorykiller/parameters/minfree`;minfree6=`awk -F , '{print $6}' /sys/module/lowmemorykiller/parameters/minfree`
oomadj1=`awk -F , '{print $1}' /sys/module/lowmemorykiller/parameters/adj`;oomadj2=`awk -F , '{print $2}' /sys/module/lowmemorykiller/parameters/adj`;oomadj3=`awk -F , '{print $3}' /sys/module/lowmemorykiller/parameters/adj`;oomadj4=`awk -F , '{print $4}' /sys/module/lowmemorykiller/parameters/adj`;oomadj5=`awk -F , '{print $5}' /sys/module/lowmemorykiller/parameters/adj`;oomadj6=`awk -F , '{print $6}' /sys/module/lowmemorykiller/parameters/adj`
if [ "$SS" -le "$oomadj1" ]; then SSKB=$minfree1;slot=1;
elif [ "$SS" -le "$oomadj2" ]; then SSMF=$minfree2;slot=2;
elif [ "$SS" -le "$oomadj3" ]; then SSMF=$minfree3;slot=3;
elif [ "$SS" -le "$oomadj4" ]; then SSMF=$minfree4;slot=4;
elif [ "$SS" -le "$oomadj5" ]; then SSMF=$minfree5;slot=5;
elif [ "$SS" -le "$oomadj6" ]; then SSMF=$minfree6;slot=6;
fi
MFK=$(($SSMF*4/6))
echo " Secondary Server ADJ = $SS"
echo " Secondary Server Slot = $slot"
echo " Secondary Server LMK MB = $((SSMF/256))"
echo " MFK (vm.min_free_kbytes)= $MFK"

I used 1/6th or 16.66%

Why?

Basically because Google did lol.

Usually stock has secondary servers killed at 24mb and MFK is usually 4096

So that works out to 1/6... and the calculator's output actually jives with what's been discussed so what the heck...

Have fun :)