[Samsung Galaxy Gio GT-S5660] AngSanley:
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:

su
fdisk -l dev/block/mmcblk0

3. You'll see something like this:

/dev/block/mmcblk0p3 1861 1924 514080 82 Linux swap

4. Do the following code, change with your exact swap partition:

su
swapon /dev/block/mmcblk0p3

*change 3 with yours

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

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:

#!/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:

/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

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)