Proposal: overcommit on, optional swap on if user decides so.

Tilman Baumann tilman at
Fri Aug 22 19:34:53 CEST 2008

Tilman Baumann wrote:
> Tilman Baumann wrote:
>>> i'd think it would make little sense so make the system
>>> that fragile. fix the memory usage issue - don't just "get more slow slow slow"
>>> ram. :)
>> As i said, i had made the experience that it improved the system 
>> greatly. Shouldn't we just test it?
>> Perhaps, that is what i will try to do with my Neo1973 soon...
> This is how swap was used after launching some apps simultaniously 
> (tangogps, navit, browser, mediaplayer) using them for some time and 
> then shut them down again:
>               total       used       free     shared    buffers     cached
> Mem:        126268     111008      15260          0       1304      68736
> -/+ buffers/cache:      40968      85300
> Swap:        64720         44      64676

Now with  sysctl vm.overcommit_memory=0
If i had knew before....

This is with tangogps, navit, mediaplayer and debug tool (python) 
running at the same time.
And still less memory used than before without these apps running!
              total       used       free     shared    buffers     cached
Mem:        126268     110124      16144          0       1472      58012
-/+ buffers/cache:      50640      75628
Swap:        64720          0      64720

This is after i closed all the apps:
              total       used       free     shared    buffers     cached
Mem:        126268      93896      32372          0       1472      56620
-/+ buffers/cache:      35804      90464
Swap:        64720          0      64720

93896Kb vs 111008Kb difference between without and with overcommit!
In words 17Mb saved.
And this is while idle. No apps running.
(I have not saved any measurement while i had lots of apps running last 
time. So i have no comparison for that.)

Suprisingly, no swap is used this time. But on the other hand not so 
suprisingly. There is tons of unused RAM free, why bother.
And maybe the 44k last time where really only some unusually leaked mem.

You can bet i will use overcommit. And because i see no downside i will 
use swap too.
I encourage openmoko and dist builders to think about it too.

For those of you who like to try. I have a quick hack.

Put these lines at the end of the initscript /etc/init.d/
if test -e /media/card/swapfile 

         swapon /media/card/swapfile
sysctl vm.overcommit_memory=0
You can choose any other file or make your own, since it is a quick hack 
i did not bother. Remember, /media/card/ needs to be mounted.

Then execute these commands once and reboot.
dd if=/dev/zero of=/media/card/swapfile bs=1024 count=65536
mkswap /media/card/swapfile

This makes 64Mb of swap, you could choose a smaller size if you want. 
Bigger is probably overkill. Depends on how valuable free SD card space 
is to you. ;)

Using a swap partition would be possible too. But then i would have 
needed to partition the SD card which i did not want to do right now.

I think i will make some scripts some time which detect the presence of 
swapfiles of swap partitions and uses them automatically.
And some small helper app to let the user prepare the system for that. 
(creating swapfile)
Should not be too bad to make.

Drucken Sie diese Mail bitte nur auf Recyclingpapier aus.
Please print this mail only on recycled paper.

More information about the community mailing list