[G2 and Desire Z Android Development] kbeezie:
If any of you are using SD Swap, DataSwap or zRam and you notice your swap usage in up higher than you expected (say for example on my system 60MB or so used with 64MB Dataswap + 10% zRam)

Here's a little shell script you can copy to /data/local/tmp, chmod 0775 on it, and then run it from adb shell via this command:

sh ./chkswap.sh | grep "Swap used" | grep -v "Swap used: 0" |sort -n -k 3

(my grep/sort knowledge is a tad limited so it could be done better).

You'll get an output similar to this, with the processes sorted from least amount of swap used to most:

Swap used: 8 - ( 1329 root 4532 S /sbin/adbd )
Swap used: 12 - ( 1328 root 5384 S /system/bin/rmt_storage /dev/block/mmcblk0p13 /dev/block/mmcblk0p14
Swap used: 20 - ( 1 root 364 S /init
Swap used: 48 - ( 1271 root 844 S /system/xbin/virtuous_oc )
Swap used: 56 - ( 1325 root 884 S /system/bin/installd )
Swap used: 60 - ( 1315 system 848 S /system/bin/servicemanager )
Swap used: 64 - ( 754 root 300 S /sbin/ueventd )
Swap used: 68 - ( 1327 compass 1184 S /system/bin/akmd )
Swap used: 68 - (18726 root 712 S /system/bin/debuggerd )
Swap used: 76 - ( 1330 root 1152 S /system/bin/htc_ebdlogd -s -k -P 7 )
Swap used: 80 - ( 3537 bluetoot 844 S /system/bin/brcm_patchram_plus --enable_hci --enable_lpm --baudrate 3000000 --patchram /vendor/firmware/b )
Swap used: 136 - ( 1324 bluetoot 1376 S /system/bin/dbus-daemon --system --nofork
Swap used: 148 - ( 1319 radio 16416 S /system/bin/rild )
Swap used: 172 - ( 1326 keystore 1788 S /system/bin/keystore /data/misc/keystore )
Swap used: 192 - ( 1316 root 4044 S /system/bin/vold )
Swap used: 200 - (31037 wifi 2476 S /system/bin/wpa_supplicant -Dwext -iwlan0 -c/data/misc/wifi/wpa_supplicant.conf -iwlan0 -c/data/misc/wifi )
Swap used: 260 - ( 1317 root 7724 S /system/bin/netd )
Swap used: 280 - ( 3716 bluetoot 2188 S /system/bin/bluetoothd -n )
Swap used: 288 - ( 1358 root 992 S /system/bin/logcat2 -v time -f /devlog/system_log -r 1024 -n 50 *:w )
Swap used: 884 - ( 1322 drm 14048 S /system/bin/drmserver )
Swap used: 1064 - ( 1323 media 40916 S /system/bin/mediaserver )
Swap used: 2124 - ( 1320 system 73516 S /system/bin/surfaceflinger )
Swap used: 6740 - (19429 system 318m S {ndroid.settings} com.android.settings )
Swap used: 6856 - (19042 app_133 286m S {facebook.katana} com.facebook.katana )
Swap used: 6932 - (18993 app_135 273m S {o.mobiledefense} com.neevo.mobiledefense )
Swap used: 7348 - (18863 app_1 280m S {d.process.acore} android.process.acore )
Swap used: 7380 - (23142 app_14 270m S {d.process.media} android.process.media )
Swap used: 7392 - (23111 app_134 275m S {ogle.android.gm} com.google.android.gm )
Swap used: 7396 - (23293 app_102 269m S {es.fancywidgets} com.anddoes.fancywidgets )
Swap used: 7412 - (18822 app_97 283m S {pps.googlevoice} com.google.android.apps.googlevoice )
Swap used: 7420 - (23250 app_130 278m S {onFriendService} com.google.android.apps.maps:LocationFriendService )
Swap used: 7444 - (23092 app_130 293m S {droid.apps.maps} com.google.android.apps.maps )
Swap used: 7444 - (23205 app_130 283m S {LocationService} com.google.android.apps.maps:NetworkLocationService )
Swap used: 7564 - (13961 app_118 277m S ccc71.bmw.pro )
Swap used: 7660 - (19492 app_11 267m S {id.defcontainer} com.android.defcontainer )
Swap used: 7688 - (23237 app_130 275m S {s:FriendService} com.google.android.apps.maps:FriendService )
Swap used: 7792 - (16806 app_10 267m S {roid.dspmanager} com.bel.android.dspmanager )
Swap used: 8060 - ( 1534 app_45 316m S {e.process.gapps} com.google.process.gapps )
Swap used: 8096 - ( 3783 app_44 306m S {.android.kineto} com.android.kineto )
Swap used: 8448 - ( 1321 root 258m S zygote /bin/app_process -Xzygote /system/bin --zygote --start-system-server )
Swap used: 8620 - ( 3861 app_41 267m S {android.smspush} com.android.smspush )
Swap used: 11064 - (26947 app_42 305m S {nddoes.launcher} com.anddoes.launcher )
Swap used: 12268 - ( 3624 system 356m S {ndroid.systemui} com.android.systemui )
Swap used: 12436 - ( 1785 system 508m S system_server )
Swap used: 19772 - ( 3762 app_66 305m S {chtype.swiftkey} com.touchtype.swiftkey )
Swap used: 20464 - ( 3778 radio 312m S {m.android.phone} com.android.phone )

From above you can see that the phone and SwiftKeys3 uses most of my swap.

My free output at the tim of running the list above looked like:

total used free shared buffers
Mem: 375916 309656 66260 0 260
-/+ buffers: 309396 66520
Swap: 103120 61532 41588

So there you have it, a scripted way to find out what's eating most of your swap. (script attached).