[Android Software/Hacking General [Developers Only]] zeppelinrox:
[Script] V6 SuperCharger! HTK & BulletProof Launchers! The ONLY Android MEMORY FIXER!

So here's how it all started... don't worry if you don't understand it...

the script does everything!

So... recently I came across/figured out some pretty neat stuff to make my

Milestone run incredibly well.

Fast, Stable, and Smooth.

FSS... heh... my Milestone

used to

make me say FFS too often... lol

In Part 2, you will find a way to make your launcher bulletproof!

What's that mean?

No more screen redraws!

AT ALL - I'm pretty sure :)

History Part 1.

How To Control Android's Memory Manager via minfree

This revolves around Android's built-in memory manager/task killer.

I had been using Auto Memory Manager (AMM) with great results. AutoKiller Memory Optimizer (AKMO) had worked just as well.

These are NOT taskillers! (And neither is my SuperCharger :D)

They tweak Android's native memory management system by editing /sys/module/lowmemorykiller/parameters/minfree

This is a "dynamic" file that gets created on boot.

There is an in-depth thread that you can read right here on XDA: How to configure Android's *internal* taskkiller

Android puts each running app into 1 of 6 Out Of Memory (OOM) groups based on their priority.

FOREGROUND_APP, VISIBLE_APP, SECONDARY_SERVER, HIDDEN_APP, CONTENT_PROVIDER, and EMPTY_APP.

Additional Info:

You can

find each app's priority and OOM.

....................... In AMM, Press Menu > Running Processes > Group by OOM grouping.

....................... Expand each group and see what apps are included and each app's priority level. (

Higher numbers get killed first!

)

....................... If you tap on an app, you can get additional info. Tip: Check and see what's included with android.process.acore ;)

The default minfree values ("kill thresholds") for each OOM group are, as far as I can tell: 6, 8, 16, 20, 22 and 24 mb. (CyanogenMod 6.1.2)

This means that:

when free memory lowers to 24 mb,

EMPTY_APPS get killed; at

22 mb free ram,

CONTENT_PROVIDER apps get killed; and so on...

Now, because the Milestone has only 256 mb of memory, I found these numbers too low, especially the 3rd one.

Basically, with those settings, you will usually be sitting with only 20 - 25 mb of ram.

Possibly less. Basically, it's the 3rd number (16) + 5. That's your free memory.

And my phone just chokes when it has that little ram available. Lag, home screen redrawing, the launcher getting killed.... ugh....

After extensive fiddling around, I've come to the conclusion that setting the third slot to about 25mb works great.

No home screen redraws while not being too aggressive on secondary/background apps while having about 30-35mb free all the time :)

BTW, free ram is

not

wasted. Android will use that memory to cache the file system and this speeds things up. See this informative post.

My other key settings

were

:

VM Heap Size = 48 mb.

Home Locked in Memory (not anymore due to my OOM Grouping Fix)

JIT enabled - You can try it on or off and decide what you like better (JIT uses some extra memory but makes the CPU more efficient)

Overclocked to 1100mhz@64 vsel.

About VM Heap size. 40 mb should be enough.

Actually, to

prevent your launcher from splitting into 2 virtual machines

, you should make it at around 40 mb.

I'm no expert about it, but that is the experience of others. (I've never tried it at 32 mb or below :p)

History Part 2.

How To Control Your Launcher Redraws by Making It Bulletproof!

Most of you know about CM's "Lock Home In Memory" setting and how we would still get screen redraws after enabling it.

My suggested AMM settings above should be enough prevent that. You should hardly ever get screen redraws anymore.

But some people were still getting them.

I tried increasing the appropriate priority (for

android.process.acore

- which includes com.android.launcher) in AMM but the setting wouldn't "stick"

Android would revert it back to where it was - in the Visible App group with a priority of 1.

I had seen how foreground apps had a priority of 0 or -12 or -16 and I came up with a

permanent solution

- "The Bulletproof Launcher"

Here's how you can have a

Bulletproof Launcher!

The line "ro.HOME_APP_ADJ=1" in /data/local.prop also keeps home in memory -

it has the same effect as CM's "Lock Home In Memory".

So in light of what I was seeing in AMM, I have

changed it to 0

so it now reads:

ro.HOME_APP_ADJ=0

(blank line)

Note:

If there isn't a blank line at the end, the ro.HOME_APP_ADJ entry gets deleted.

If you do this and reboot, AMM may still show that android.process.acore (or whereever your launcher is) with a priority of 1

If that's the case, disabled CM's setting to lock home in memory.

Now, if you go back to AMM, you should see that android.process.acore is now a foreground app with a priority of 0... BOOYA!

Notes:

Obviously, CM's "Lock Home In Memory" overrides the setting in local.prop.

.......... CM will set the priority back to 1 after local.prop gives a priority of 0.

.......... That's why CM's setting has to be disabled - so that the local.prop setting will "stick"

.......... Gaming Tip - You can use CM's lock home in memory as a

"Safety Lock"

- to toggle your launcher from Bulletproof (0) to Killable (1)

............................. If having problems with a game, put the "Safety Lock" on so the launcher is "killable" so android can free up some extra ram.

Note that BulletProofing is NO LONGER RECOMMENDED! The Hard To Kill Launcher is the PERFECT SOLUTION!

History Part 3.

Blah Blah Blah...

Interesting Notes:

I had installed the Telus Froyo Update yesterday (03/25/11) and still have it installed.

.......................... Only now did I think to look at the minfree values :p

.......................... 8, 12, 24, 28, 32, 32 <--- Telus Froyo. I'm a little

shocked

by the

3rd slot

, 24mb?! :eek:

.......................... 6, 8, 24, 26, 28, 30 <----- See, I'm not crazy! Telus Froyo values are very similar to my

Balanced Settings

:cool:

.......................... In comparison, my Balanced script

keeps your foreground apps alive longer

, same free ram &

more friendly to background apps!

.......................... For completeness:

.......................... 6, 8, 16, 20, 22, 24 <---- CM6 (Froyo)

.......................... 6, 8, 12, 16, 24, 32 <---- CM7 (Gingerbread)

.......................... 8, 12, 16, 24, 28, 32 <--- Google's Gingbread values, according to this.

Moved from OP

(old Change Log)

UPDATED July 21, 2011:

- Update 8

Improved code

Tweaked Current Status functionality. It will tell you if your current and prior minfrees match but if you apply a setting, it won't update the "prior minfrees" with the values you just installed. It will update the prior minfrees the next time you run the script.

UPDATED July 18, 2011:

- Update 7

Tweaked Status Checker. Update 6 sometimes gave wrong launcher status :p

UPDATED July 16, 2011:

- Update 6

Added Second MegaRAM device setting.

Added installation to system option - for easy use with Terminal Emulator!

Added UnSuperCharger verification

Improved status checker. It can sometimes determine if home is locked in memory! If not, it asks you if it is.

Saves SuperCharger settings! - They are displayed on the main menu if they exist.

Saves Cust-OOM settings! - Cust-OOM settings get added to the menu!

Smart Cust-OOMizer - Just try it :)

Improved the code some more. It's smarter than ever :)

Improved messages to user. Clearer instructions and errors are given!

Final attempt to get this to load on boot. Custom ROMs will now get the /data/userinit.sh and /data/99SuperCharger.sh files.

Easily cook into your rom! Just change the variable (rcpath=) on line 116 to the path of your *rc file!

1224 lines of code! :eek: :cool:

UPDATED June 29, 2011:

- Update 5

Removed 2 minute delay from userinit.sh. Sorry, I didn't know that it would pause the boot process on some phones/roms

UPDATED June 26, 2011:

- Update 4

Fixed issue with error check - commented it out as it would stop the script dead on some roms :p

Improved Status Checker some more

Improved the code. The script is much smarter, cleaner and efficient (no more temp files)

1001 lines of code!

UPDATED June 25, 2011:

- Update 3b

Pulled earlier Update 3 - fixed minor noticeable errors and one HUGE one that went unnoticed...

UPDATED June 25, 2011:

- Update 3 -PULLED

Added error check that exits script on any error

Tweaked OOM groupings/priorities (Froyo is the same as always, Gingerbread now takes into account Perceptible App)

Improved Status Checker

ReReFixed!? userinit.sh now used

as a launcher for 99SuperCharger - with a 2 minute delay!

(This boot script fix HAS to work :p)

Fixed sysctl error on some phone configurations

UPDATED June 20, 2011:

- Update 2

Added User Selectable Scrolling Speed!

Fixed a couple of weird issues that some people had in yesterday's update :p

ReFixed? Still trying to get the 99SuperCharger boot script to load automatically for everybody... grrrrr...

UPDATED June 19, 2011:

- Update 1

Added

MegaMemory Device

setting!

Fixed formatting for Script Manager update (40 columns)

Fixed (I hope) boot script not booting on many ROMs

Fixed long press back button kill (wasn't working)

Modified OOM groupings/priorities: Nothing breaks... EVER!

Improved the help html files

Was this useful info? If so...

Please HIT THANKS and Give a 5 Star Rating!