[HowTo] Use swap to get much more performance !

Search This thread

devrieshh

Senior Member
Mar 27, 2011
270
27
How to check if it works? I am not sure, I have the feeling that it works, it feels faster, but I am not sure if the swapp solution realy is installed

Sent from my GT-S5660 using XDA Free mobile app
 

doctor-who

Senior Member
Jul 25, 2014
680
95
Bogatic
I've noticed that swap is useful if you wanna run apps heavy on ram in 1 time like skype
But I using some swap on/off from playstore by sylkat. Because don't need swap always and why to decrease my sd card

Sent from my GT-5660 using Tapatalk 2
 

Attachments

  • uploadfromtaptalk1415715230533.jpg
    uploadfromtaptalk1415715230533.jpg
    23.6 KB · Views: 164

Top Liked Posts

  • There are no posts matching your filters.
  • 9


    What is Swap?

    Linux divides its physical RAM (random access memory) into chucks of memory called pages. Swapping is the process whereby a page of memory is copied to the preconfigured space on the hard disk, called swap space, to free up that page of memory. The combined sizes of the physical memory and the swap space is the amount of virtual memory available.

    Swapping is necessary for two important reasons. First, when the system requires more memory than is physically available, the kernel swaps out less used pages and gives memory to the current application (process) that needs the memory immediately. Second, a significant number of the pages used by an application during its startup phase may only be used for initialization and then never used again. The system can swap out those pages and free the memory for other applications or even for the disk cache.

    However, swapping does have a downside. Compared to memory, disks are very slow. Memory speeds can be measured in nanoseconds, while disks are measured in milliseconds, so accessing the disk can be tens of thousands times slower than accessing physical memory. The more swapping that occurs, the slower your system will be. Sometimes excessive swapping or thrashing occurs where a page is swapped out and then very soon swapped in and then swapped out again and so on. In such situations the system is struggling to find free memory and keep applications running at the same time. In this case only adding more RAM will help.

    Linux has two forms of swap space: the swap partition and the swap file. The swap partition is an independent section of the hard disk used solely for swapping; no other files can reside there. The swap file is a special file in the filesystem that resides amongst your system and data files.


    I want that on my Phone, how to do that?
    Okay, here goes the real story. Since Android is Linux, that would be possible.

    What is needed:
    - Fast (Class 10) Micro-SD Card, if you dont have class 10, class 4 would be great too..
    - CWM or Partitioning software
    - Root (of course :D)
    - Terminal Emulator app
    - Kernel with swap and init.d support (for example our CM7, 9, 10 and 10.1 ROM)
    - Root Exploring app (for example Root Browser or Root Explorer)

    Steps:
    1. Partition your SD Card, Ask Google how to do that. Make new Swap partition, or you want SD-ext too..
    2. Open Terminal Emulator, do:
    Code:
    su
    fdisk -l dev/block/mmcblk0

    3. You'll see something like this:
    Code:
    /dev/block/mmcblk0p3            1861        1924      514080  82 Linux swap

    4. Do the following code, change with your exact swap partition:
    Code:
    su
    swapon /dev/block/mmcblk0p3

    *change 3 with yours

    5. Now you can check your swap partition by doing:
    Code:
    free

    Now we create the script to do that automatically at boot
    1. Open Root exploring apps, head to /system/etc/init.d
    2. Make a new file, named 05swap
    3. Edit that file, copy this up:
    Code:
    #!/system/bin/sh
    echo Swap enabled
    swapon -a

    4. Save it and change the permission to :
    V V V
    V V V
    V V V

    *tick all the boxes (rwxrwxrwx)

    5. Now head to /system/etc and create new file named fstab
    6. Open it and enter this:
    Code:
    /dev/block/mmcblk0p3 swap swap
    *remember, change the 3 with yours

    Now we set the swappiness value
    *the normal value is 60, but you can change to what number you want (max 100). Higher may help to improve overall performance, while setting it to lower may increase interactivity and overall stability.

    1. Do this on Terminal Emulator
    Code:
    su
    echo vm.swappiness=60 >> /system/etc/sysctl.conf

    2. Reboot and you're done. ;)

    Thanks to:
    - Linux.com (for the swap definitions)
    - Segnale007 (for the swap how to)

    2


    Now we set the swappiness value
    *the normal value is 60, but you can change to what number you want (max 100). Higher may help to improve overall performance, while setting it to lower may increase interactivity and overall stability.

    1. Do this on Terminal Emulator
    Code:
    su
    echo vm.swappiness=60 >> /system/etc/sysctl.conf


    I can't find this file! I am in JellyBean 4.2.2, maybe its different file?

    /system/etc/sysctl.conf
    2
    I can't find this file! I am in JellyBean 4.2.2, maybe its different file?

    /system/etc/sysctl.conf

    Create it, new file

    Btw i say do it in the terminal emulator, its easier

    Sent from my GT-S5660 using xda premium
    1
    u need to partition ur sdcard first

    I get a error on your first step

    "fdisk: can't open 'dev/block/mmcblk0': No such file or directory" :(

    Is because the command does not use system path, it assumes you're in '/'.
    Just use
    fdisk -l /dev/block/mmcblk0

    Sent from my GT-S5660 using xda app-developers app
    1
    Can Plead
    Please provide a zip file
    To install the Recovery
    Thank