to not to repartition my SD card, instead i use a file on /data as swap partition.
Sometimes the swap seems to help, at least i have less out-of-memory cases...
So here is the trick.
First you have to make a swapfile (you can do it on your SD card as well),
use adb shell and su to become root (to have access to /data/local)
# dd if=/dev/zero of=/data/local/swapfile bs=1048576 count=400 #400MB # mkswap /data/local/swapfile
Then you have to write a script which enables the swap during boot,
lets use userinit.sh for the filename, and (adb) push it to /data/local
this script will be called automatically by the CyanogenMod init.d at the boot.
#!/system/bin/sh L="log -p i -t swap" SWAPFILE=/data/local/swapfile $L "Activating SWAP ..." if [ -f $SWAPFILE ]; then /system/xbin/swapon $SWAPFILE $L "SWAP activated." else $L "SWAP not activated. ($SWAPFILE not exists)" fi
Finally lets add an executable bit to the script (adb shell and su again)
(and you can start it manually right now, so no need for reboot)
# chmod 0777 /data/local/userinit.sh # /data/local/userinit.sh
And now you can check if it it succeed:
# free -m | grep Swap Swap: 409596 42176 367420
I tried with this CyanogenMod build, but this trick may works with the other CMs too: