Solution to low memory issues and lag?

hardcore

Senior Member
Sep 12, 2006
3,435
7,990
0
EDIT: These settings don't seem to be read by the lowmemorykiller process, so they have no effect. But the app Autokiller modifies the settings in /sys/module/lowmemorykiller/parameters/minfree and that one works!

Hey guys, I just noticed this thread and it's very interesting.

http://forum.xda-developers.com/showthread.php?t=622666

Android has its own low memory task killer, and it can be configured. I checked the defaults for my JPC Froyo firmware, and it was set a bit low, meaning processes are not killed as soon as they should be.

I also think I've found a new way to configure those options:

I modified my /system/build.prop file and added the following lines.

# tune the lowmemorykiller
ro.FOREGROUND_APP_MEM=5120
ro.VISIBLE_APP_MEM=8192
ro.SECONDARY_SERVER_MEM=12288
ro.BACKUP_APP_MEM=12288
ro.HOME_APP_MEM=12288
ro.HIDDEN_APP_MEM=20480
ro.CONTENT_PROVIDER_MEM=22528
ro.EMPTY_APP_MEM=24576

Reboot for it to take effect.

These values are twice my original ones. You can check current values by doing a "getprop".

NOTE that these values are in PAGES (4K). So 24567 pages = 98,304 KBytes.

Strangely the /sys/module/lowmemorykiller/parameters/minfree values are not changed. But I think the lowmemorykiller might be reading the prop values directly. I'm running many programs now trying to hit the limit and see if it takes effect.

EDIT: It seems to be working! I can run many many apps and the phone remains responsive. Unused apps are killed as needed. Check out the screenshots below:
 

Attachments

Last edited:

distortedloop

Senior Member
Feb 14, 2010
3,200
335
0
Los Angeles, CA
Isn't this pretty old news?

Aren't there are apps in the Market for this (AutoKiller, MinFreeMgr)?

I guess if you know precisely the best settings for your own phone, putting them in a startup script makes sense. I didn't realize build.prop could be used to set things like that.
 

hardcore

Senior Member
Sep 12, 2006
3,435
7,990
0
Isn't this pretty old news?

Aren't there are apps in the Market for this (AutoKiller, MinFreeMgr)?

I guess if you know precisely the best settings for your own phone, putting them in a startup script makes sense. I didn't realize build.prop could be used to set things like that.
MinFreeMgr tries to do the same thing but by editing a different file which doesn't stay on reboot. This build.prop edit is a new finding, and it seems to work. I think it could be a better solution as it stays after a reboot. The difference between this and other Auto Task Killers is that this is using Android's built-in memory management mechanism which is much smarter than any external task killer can be.

So far it works really well!
 

distortedloop

Senior Member
Feb 14, 2010
3,200
335
0
Los Angeles, CA
MinFreeMgr tries to do the same thing but by editing a different file which doesn't stay on reboot. This build.prop edit is a new finding, and it seems to work. I think it could be a better solution as it stays after a reboot. The difference between this and other Auto Task Killers is that this is using Android's built-in memory management mechanism which is much smarter than any external task killer can be.

So far it works really well!
Yeah, I acknowledged the build.prop was interesting, very interesting, actually. I wonder if you could set other parameters in there that some of the modders are throwing into init scripts and/or small apps.

For clarification, the two Market-available apps I mentioned (AutoKiller, MinFreeMgr), both do the exact same thing you're talking about. AutoKiller is poorly named, as it's not a task killer per se, it merely modifies on the fly the settings you're talking about here; same with MinFreeMgr. Both can be set to take affect at startup/reboot. Advantage, can be changed on the fly without reboot, disadvantage, another app to load during reboot.

Thanks.
 

hardcore

Senior Member
Sep 12, 2006
3,435
7,990
0
For clarification, the two Market-available apps I mentioned (AutoKiller, MinFreeMgr), both do the exact same thing you're talking about. AutoKiller is poorly named, as it's not a task killer per se, it merely modifies on the fly the settings you're talking about here; same with MinFreeMgr. Both can be set to take affect at startup/reboot. Advantage, can be changed on the fly without reboot, disadvantage, another app to load during reboot.
Ah, thanks for clarifying that. I discovered those values when I did a getprop. The values I posted above (2x default) work okay. But now I'm trying slightly less aggressive values (1.5x) to see what might be the optimum - too much free RAM is also a waste.
 

distortedloop

Senior Member
Feb 14, 2010
3,200
335
0
Los Angeles, CA
By the way, what task manager is that your pics are of? Looks like the Samsung Task Manager, except the RAM tab. On mine, that tab's Summary and does not give the same info as yours. Mine's unchanged on the various firmwares I have used JG1, JG5, JM1, JM5, JM6, JH1, JM7...
 

hardcore

Senior Member
Sep 12, 2006
3,435
7,990
0
By the way, what task manager is that your pics are of? Looks like the Samsung Task Manager, except the RAM tab. On mine, that tab's Summary and does not give the same info as yours. Mine's unchanged on the various firmwares I have used JG1, JG5, JM1, JM5, JM6, JH1, JM7...
You're right. Its the JPC Task Manager. It has those extra options to clear the memory. I don't use them now though.
 

nanoo-eg

Senior Member
Aug 27, 2008
391
34
0
Cairo
With Eclair I have 326MB ram. Froyo has less just 304.
And after we speak for galaxy lag. I thing it is an android lag because the system to start cut ram from frozen apps and to give at the new application they try to open, the free ram must be 48mb.
Very less for the UI.
I am not happy. We let WM so as to don't need fixes and custom rom. And we have other problems.
 
Last edited:

g00ndu

Retired Recognized Developer
Apr 22, 2008
2,781
273
0
I will give it a try. Already modified my build.prop and un-installed Autokiller. Will check for the next few days.

P/S: Probably due to placebo effect, but it feels more responsive.

If it works, this is a good hack!
 

g00ndu

Retired Recognized Developer
Apr 22, 2008
2,781
273
0
By the way, what task manager is that your pics are of? Looks like the Samsung Task Manager, except the RAM tab. On mine, that tab's Summary and does not give the same info as yours. Mine's unchanged on the various firmwares I have used JG1, JG5, JM1, JM5, JM6, JH1, JM7...
That's the froyo task manager, which can be found in the earlier froyo (xxjp3) release as well.

If you want, i can attach this apk (either odexed or deodex, you pick) for you to try on eclair. :)
 

YG007

Senior Member
Jul 26, 2010
134
33
0
GTA
Hey guys, I just noticed this thread and it's very interesting.

http://forum.xda-developers.com/showthread.php?t=622666

Android has its own low memory task killer, and it can be configured. I checked the defaults for my JPC Froyo firmware, and it was set a bit low, meaning processes are not killed as soon as they should be.

I also think I've found a new way to configure those options:

I modified my build.prop file and added the following lines.

# tune the lowmemorykiller
ro.FOREGROUND_APP_MEM=5120
ro.VISIBLE_APP_MEM=8192
ro.SECONDARY_SERVER_MEM=12288
ro.BACKUP_APP_MEM=12288
ro.HOME_APP_MEM=12288
ro.HIDDEN_APP_MEM=20480
ro.CONTENT_PROVIDER_MEM=22528
ro.EMPTY_APP_MEM=24576
Hey, I was thinking about this, and I started to do some research and found that for Froyo, other devices are using these as parameters:

ro.FOREGROUND_APP_MEM 1536
ro.VISIBLE_APP_MEM 2048
ro.SECONDARY_SERVER_MEM 4096
ro.BACKUP_APP_MEM 4096
ro.HOME_APP_MEM 1536
ro.HIDDEN_APP_MEM 5120
ro.CONTENT_PROVIDER_MEM 8192
ro.EMPTY_APP_MEM 10240

I'm just wondering if we should be increasing the memory sizes or decreasing them?? Maybe do a combination of both?? I gotta do more research, find out how each attribute behaves, and get more info before editing this stuff. :D
 

hardcore

Senior Member
Sep 12, 2006
3,435
7,990
0
Hey, I was thinking about this, and I started to do some research and found that for Froyo, other devices are using these as parameters:

ro.FOREGROUND_APP_MEM 1536
ro.VISIBLE_APP_MEM 2048
ro.SECONDARY_SERVER_MEM 4096
ro.BACKUP_APP_MEM 4096
ro.HOME_APP_MEM 1536
ro.HIDDEN_APP_MEM 5120
ro.CONTENT_PROVIDER_MEM 8192
ro.EMPTY_APP_MEM 10240

I'm just wondering if we should be increasing the memory sizes or decreasing them?? Maybe do a combination of both?? I gotta do more research, find out how each attribute behaves, and get more info before editing this stuff. :D
I think increasing is better if you want apps to be auto killed. The default values (for JPC at least) are half of what I suggested. And it didn't seem to be aggressive enough for the SGS.
 

g00ndu

Retired Recognized Developer
Apr 22, 2008
2,781
273
0
I think increasing is better if you want apps to be auto killed. The default values (for JPC at least) are half of what I suggested. And it didn't seem to be aggressive enough for the SGS.
Just a side topic, saw your CSC is OLBJG4, did you manage to flash and got it configured automatically, or that *#272*HHMM# still does not work, and you have to set the apn manually?
 

distortedloop

Senior Member
Feb 14, 2010
3,200
335
0
Los Angeles, CA
But now I'm trying slightly less aggressive values (1.5x) to see what might be the optimum - too much free RAM is also a waste.
That's the mantra in linux "free memory is wasted memory." ;)

I first saw this stuff discussed here. Probably nothing you haven't figured out yet.

I think the settings for any individual are going to vary; there is no set answer, too much of variable in how you use your phone and what apps you use, etc.

You might check out "AutoKiller", it's free, and has some presets, along with ability to roll your own settings. I'd play with it until I found the numbers I liked best, then you could bake them into your build.prop. That would save you the slight hassle of editing and rebooting.

You can also just echo them from the terminal app, but I'm sure you already knew that.

But for those who don't, here's a sample from the above linked article:

Code:
su
echo "1536,2048,4096,5120,15360,23040" > /sys/module/lowmemorykiller/parameters/minfree
Also, while you're playing with settings, have you also looked at changing the i/o scheduler. Lots of debate over what's best. Again, I think it just depends on how you as an individual use your phone...
 

hardcore

Senior Member
Sep 12, 2006
3,435
7,990
0
Just a side topic, saw your CSC is OLBJG4, did you manage to flash and got it configured automatically, or that *#272*HHMM# still does not work, and you have to set the apn manually?
I sortof hacked it into my /system folder manually. Just need to replace some files there. Auto APN does work. Maybe I'll write up a procedure when I'm more sure of it.
 
Last edited: