Swap shoots to 100% after a couple of hours of usage

For some reason or another, my swap usage will peak to 100% capacity after a couple hours of usage. My interface will then freeze, after which I have to wait 20 minutes time to be able to even move the mouse.

The current suspected culprit is Chromium or XChat as these are always present when this issue occurs. I'm leaning more towards XChat as I've previously noticed the freeze starting right around the time when I click on something related to XChat.

Among the other things I've noticed is the Swap usage will build up over time.

I've also had Emesene and Dropbox open, but i doubt they're the root cause of the issue as they're just idling when the interface freezes.

Rebooting is currently my only fix at the moment, (That I can find anyway...)but if the interface didn't completely stop working, in that case it would be a hard reset. Also when the swap is full, the HDD light is constantly on. Not sure why this is happening

Edit: Found some additional information. Here's the output of free -m:

             total       used       free     shared    buffers     cached
Mem:          3760       3653        107          0          4       2638
-/+ buffers/cache:       1010       2750
Swap:         3890       2643       1247

As you can see, the physical memory is cached for some reason, while the free ones are relatively small. I think this is causing the swap usage.

I need this fixed as I currently need to shutdown every 2 days.

Thanks

Update: As per request /etc/fstab

UUID=20fab2bb-2424-40b0-ae2b-74693ea83f45 /               ext4    errors=remount-ro,user_xattr 0       1
# swap was on /dev/sda5 during installation
UUID=e04c1c74-9b99-4f07-8d3c-f0d6e8d3c465 none            swap    sw              0       0

Update:

ps -aux info

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.0  24144  1968 ?        Ss   Jul11   0:02 /sbin/init
root         2  0.0  0.0      0     0 ?        S    Jul11   0:00 [kthreadd]
root         3  0.0  0.0      0     0 ?        S    Jul11   0:00 [ksoftirqd/0]
root         6  0.0  0.0      0     0 ?        S    Jul11   0:00 [migration/0]
root        17  0.0  0.0      0     0 ?        S<   Jul11   0:00 [cpuset]
root        18  0.0  0.0      0     0 ?        S<   Jul11   0:00 [khelper]
root        19  0.0  0.0      0     0 ?        S<   Jul11   0:00 [netns]
root        21  0.0  0.0      0     0 ?        S    Jul11   0:00 [sync_supers]
root        22  0.0  0.0      0     0 ?        S    Jul11   0:00 [bdi-default]
root        23  0.0  0.0      0     0 ?        S<   Jul11   0:00 [kintegrityd]
root        24  0.0  0.0      0     0 ?        S<   Jul11   0:00 [kblockd]
root        25  0.0  0.0      0     0 ?        S<   Jul11   0:00 [ata_sff]
root        26  0.0  0.0      0     0 ?        S    Jul11   0:00 [khubd]
root        27  0.0  0.0      0     0 ?        S<   Jul11   0:00 [md]
root        30  0.0  0.0      0     0 ?        S    Jul11   0:00 [khungtaskd]
root        31  0.0  0.0      0     0 ?        S    Jul11   0:05 [kswapd0]
root        32  0.0  0.0      0     0 ?        SN   Jul11   0:00 [ksmd]
root        33  0.0  0.0      0     0 ?        SN   Jul11   0:00 [khugepaged]
root        34  0.0  0.0      0     0 ?        S    Jul11   0:00 [fsnotify_mark]
root        35  0.0  0.0      0     0 ?        S    Jul11   0:00 [ecryptfs-kthr]
root        36  0.0  0.0      0     0 ?        S<   Jul11   0:00 [crypto]
root        40  0.0  0.0      0     0 ?        S<   Jul11   0:00 [kthrotld]
root        43  0.0  0.0      0     0 ?        S<   Jul11   0:00 [kmpathd]
root        44  0.0  0.0      0     0 ?        S<   Jul11   0:00 [kmpath_handle]
root       273  0.0  0.0      0     0 ?        S    Jul11   0:00 [scsi_eh_0]
root       274  0.0  0.0      0     0 ?        S    Jul11   0:00 [scsi_eh_1]
root       275  0.0  0.0      0     0 ?        S    Jul11   0:00 [scsi_eh_2]
root       276  0.0  0.0      0     0 ?        S    Jul11   0:00 [scsi_eh_3]
root       277  0.0  0.0      0     0 ?        S    Jul11   0:01 [scsi_eh_4]
root       279  0.0  0.0      0     0 ?        S    Jul11   0:00 [scsi_eh_5]
root       353  0.0  0.0      0     0 ?        S    Jul11   0:01 [jbd2/sda1-8]
root       354  0.0  0.0      0     0 ?        S<   Jul11   0:00 [ext4-dio-unwr]
root       404  0.0  0.0  17052   520 ?        S    Jul11   0:00 upstart-udev-br
root       414  0.0  0.0  21536   652 ?        S<s  Jul11   0:00 udevd --daemon
root       627  0.0  0.0      0     0 ?        S    Jul11   0:00 [ips-adjust]
root       630  0.0  0.0      0     0 ?        S    Jul11   0:02 [ips-monitor]
root       631  0.0  0.0      0     0 ?        S<   Jul11   0:00 [kmemstick]
root       655  0.0  0.0      0     0 ?        S<   Jul11   0:00 [kpsmoused]
root       657  0.0  0.0      0     0 ?        S<   Jul11   0:00 [cfg80211]
root       806  0.0  0.0  15004   496 ?        S    Jul11   0:00 upstart-socket-
root       819  0.0  0.0      0     0 ?        S<   Jul11   0:00 [iwlagn]
root       858  0.0  0.0      0     0 ?        S<   Jul11   0:00 [l2cap]
root       911  0.0  0.0      0     0 ?        S<   Jul11   0:00 [hd-audio0]
root       920  0.0  0.0      0     0 ?        S<   Jul11   0:00 [hd-audio1]
syslog     989  0.0  0.0 119988   924 ?        Sl   Jul11   0:00 rsyslogd -c4
102       1002  0.0  0.0  25496  2316 ?        Ss   Jul11   0:18 dbus-daemon --s
root      1014  0.0  0.0  83168  2848 ?        Ssl  Jul11   0:00 gdm-binary
avahi     1018  0.0  0.0  32132  1336 ?        S    Jul11   0:00 avahi-daemon: r
avahi     1019  0.0  0.0  32008   156 ?        S    Jul11   0:00 avahi-daemon: c
root      1020  0.0  0.0 158344  3452 ?        Ssl  Jul11   0:06 NetworkManager
root      1022  0.0  0.0 125528  2376 ?        Sl   Jul11   0:01 /usr/sbin/conso
root      1037  0.0  0.0  64656  1972 ?        S    Jul11   0:00 /usr/sbin/modem
root      1113  0.0  0.0 136612  3404 ?        Sl   Jul11   0:02 /usr/lib/policy
root      1130  0.0  0.0  77284  2012 ?        Ss   Jul11   0:00 /usr/sbin/cupsd
root      1170  0.0  0.0  97816  2704 ?        Sl   Jul11   0:00 /usr/lib/gdm/gd
root      1180  0.0  0.0   6196   528 tty4     Ss+  Jul11   0:00 /sbin/getty -8
root      1183  0.0  0.0   6196   528 tty5     Ss+  Jul11   0:00 /sbin/getty -8
root      1196  0.0  0.0   6196   532 tty2     Ss+  Jul11   0:00 /sbin/getty -8
root      1199  0.0  0.0   6196   528 tty3     Ss+  Jul11   0:00 /sbin/getty -8
root      1204  0.0  0.0   6196   528 tty6     Ss+  Jul11   0:00 /sbin/getty -8
root      1214  0.0  0.0   4416   784 ?        Ss   Jul11   0:00 acpid -c /etc/a
root      1217  0.0  0.0  18928   844 ?        Ss   Jul11   0:00 cron
daemon    1220  0.0  0.0  16728   200 ?        Ss   Jul11   0:00 atd
root      1230  1.8  1.1 533108 44700 tty7     Ss+  Jul11  32:07 /usr/bin/X :0 -
mysql     1245  0.0  0.0 168744  2572 ?        Ssl  Jul11   0:10 /usr/sbin/mysql
root      1248  0.0  0.0  15780   564 ?        Ss   Jul11   0:05 /usr/sbin/irqba
root      1262  0.0  0.0  28932  1260 ?        S    Jul11   0:01 /sbin/wpa_suppl
root      1292  0.0  0.0   4400   368 ?        S    Jul11   0:00 /usr/sbin/hddte
root      1411  0.0  0.0  37364  1092 ?        Ss   Jul11   0:00 /usr/lib/postfi
root      1465  0.0  0.0  65800   672 ?        Ss   Jul11   0:00 /usr/sbin/winbi
root      1535  0.0  0.0      0     0 ?        S<   Jul11   0:00 [krfcommd]
root      1569  0.0  0.0 173652  1308 ?        Ss   Jul11   0:00 /usr/sbin/apach
www-data  1582  0.0  0.0 173652   236 ?        S    Jul11   0:00 /usr/sbin/apach
www-data  1583  0.0  0.0 173652   236 ?        S    Jul11   0:00 /usr/sbin/apach
www-data  1584  0.0  0.0 173652   236 ?        S    Jul11   0:00 /usr/sbin/apach
www-data  1585  0.0  0.0 173652   236 ?        S    Jul11   0:00 /usr/sbin/apach
www-data  1586  0.0  0.0 173652   236 ?        S    Jul11   0:00 /usr/sbin/apach
root      1630  0.0  0.0      0     0 ?        S    Jul11   0:00 [flush-8:0]
root      1637  0.0  0.0  65800   224 ?        S    Jul11   0:00 /usr/sbin/winbi
root      1766  0.0  0.0   6196   528 tty1     Ss+  Jul11   0:00 /sbin/getty -8
root      1820  0.0  0.0 135156  2396 ?        Sl   Jul11   0:00 /usr/lib/gdm/gd
rtkit     1825  0.0  0.0 103164  1040 ?        SNl  Jul11   0:00 /usr/lib/rtkit/
root      1830  0.0  0.1 144204  4276 ?        Sl   Jul11   0:15 /usr/lib/upower
ulti    2065  0.0  0.1 189116  3896 ?        Sl   Jul11   0:00 /usr/bin/gnome-
ulti    2084  0.0  0.1 243352  6428 ?        Ssl  Jul11   0:03 gnome-session -
ulti    2116  0.0  0.0  60840  3028 ?        Sl   Jul11   0:31 /usr/bin/ibus-d
ulti    2120  0.0  0.0  12092    16 ?        Ss   Jul11   0:00 /usr/bin/ssh-ag
ulti    2123  0.0  0.0  26400   328 ?        S    Jul11   0:00 /usr/bin/dbus-l
ulti    2124  0.0  0.0  27712  3128 ?        Ss   Jul11   1:15 //bin/dbus-daem
ulti    2126  0.0  0.0 130548  2792 ?        Sl   Jul11   0:00 /usr/lib/ibus/i
ulti    2128  0.0  0.5 456024 19524 ?        Sl   Jul11   0:41 /usr/bin/python
ulti    2130  0.0  0.1 145864  5700 ?        S    Jul11   0:00 /usr/lib/ibus/i
ulti    2135  0.0  0.1  61484  3972 ?        S    Jul11   0:04 /usr/lib/libgco
ulti    2137  0.0  0.1  72168  5692 ?        S    Jul11   0:03 /usr/lib/ibus-p
ulti    2145  0.0  0.2 474668  8128 ?        Ssl  Jul11   0:18 /usr/lib/gnome-
ulti    2149  0.0  0.3 344292 14180 ?        Sl   Jul11   0:22 /usr/lib/notify
ulti    2158  0.0  0.0  55960  2148 ?        S    Jul11   0:00 /usr/lib/gvfs/g
ulti    2163  0.0  0.0  81008  1488 ?        Ssl  Jul11   0:00 /usr/lib/gvfs//
ulti    2167  0.3  0.2 279904  8684 ?        Sl   Jul11   6:35 /usr/bin/compiz
ulti    2186  0.0  0.0  22608   768 ?        S    Jul11   0:13 syndaemon -i 0.
ulti    2188  0.0  0.0 161972  3272 ?        S    Jul11   0:00 /usr/lib/gvfs/g
root      2191  0.0  0.0 136120  3504 ?        Sl   Jul11   0:00 /usr/lib/udisks
root      2192  0.0  0.0  45168   804 ?        S    Jul11   0:02 udisks-daemon: 
ulti    2195  0.0  0.0  77352  1752 ?        Sl   Jul11   0:01 /usr/lib/gvfs/g
ulti    2198  0.0  0.0  63556  2028 ?        S    Jul11   0:00 /usr/lib/gvfs/g
ulti    2199  0.1  1.4 738152 55152 ?        Sl   Jul11   2:27 nautilus
ulti    2201  0.0  0.4 398040 16004 ?        SLl  Jul11   0:25 nm-applet --sm-
ulti    2202  0.0  0.1 347020  6020 ?        Sl   Jul11   0:00 /usr/lib/evolut
ulti    2203  0.0  0.2 317560  8580 ?        Sl   Jul11   0:00 bluetooth-apple
ulti    2204  0.0  0.1 289280  5972 ?        Sl   Jul11   0:01 zeitgeist-datah
ulti    2207  0.0  0.4 381248 18424 ?        Sl   Jul11   0:16 gnome-panel
ulti    2211  0.0  0.2 339028 10792 ?        Sl   Jul11   0:00 /usr/lib/policy
ulti    2212  0.0  0.6 478920 24388 ?        Sl   Jul11   0:02 synapse --start
ulti    2219  0.0  0.3 188988 11680 ?        Sl   Jul11   0:02 /usr/bin/python
ulti    2221  0.1  0.3 995912 13024 ?        Sl   Jul11   2:20 python /usr/bin
ulti    2223  0.0  0.3 480188 13952 ?        Sl   Jul11   0:40 gnome-power-man
ulti    2232  0.0  0.5 688680 20392 ?        Ssl  Jul11   0:20 /home/ulti/.d
ulti    2235  0.0  0.0  10848   452 ?        S    Jul11   0:00 /bin/cat
ulti    2240  0.0  0.1 330376  5452 ?        Sl   Jul11   0:01 /usr/lib/evolut
ulti    2243  0.0  0.0      0     0 ?        Z    Jul11   0:00 [zei] <defunct>
ulti    2261  0.0  0.1 180360  5624 ?        S    Jul11   0:00 /usr/lib/gnome-
ulti    2325  0.0  0.2 281168  8304 ?        Sl   Jul11   0:00 /usr/lib/gnome-
ulti    2327  0.0  0.0  60780  2912 ?        S    Jul11   0:00 /usr/lib/gvfs/g
ulti    2330  0.0  0.0  56812  2496 ?        S    Jul11   0:00 /usr/bin/obex-d
ulti    2331  0.0  0.1 245636  5244 ?        Ss   Jul11   0:04 gnome-screensav
ulti    2348  0.0  0.0   4220   488 ?        Ss   Jul11   0:00 /bin/sh -c /usr
ulti    2349  0.0  0.3 339428 13760 ?        Sl   Jul11   0:18 /usr/bin/unity-
ulti    2351  0.0  0.0 161388  2380 ?        Ssl  Jul11   0:00 /usr/lib/bonobo
ulti    2368  0.0  0.3 346704 15276 ?        Sl   Jul11   1:09 /usr/lib/gnome-
ulti    2371  0.0  0.2 372276 10936 ?        Sl   Jul11   0:21 /usr/lib/gnome-
ulti    2373  0.0  0.2 298172  9268 ?        Sl   Jul11   0:00 /usr/lib/gnome-
ulti    2375  0.4  0.5 415272 21692 ?        Sl   Jul11   7:48 /usr/lib/indica
ulti    2377  0.0  0.2 276272  8636 ?        Sl   Jul11   0:24 /usr/lib/gnome-
ulti    2411  0.0  0.0  49920  2144 ?        S    Jul11   0:00 /usr/lib/gvfs/g
ulti    2414  0.0  0.0 122464  2396 ?        Sl   Jul11   0:00 /usr/lib/d-conf
ulti    2421  0.0  0.1 305576  4624 ?        Sl   Jul11   0:00 /usr/lib/indica
ulti    2423  0.0  0.1 227072  4028 ?        Sl   Jul11   0:00 /usr/lib/indica
ulti    2425  0.0  0.1 405464  4152 ?        Sl   Jul11   0:01 /usr/lib/indica
ulti    2427  0.0  0.1 315800  6724 ?        Sl   Jul11   0:01 /usr/lib/indica
ulti    2429  0.0  0.1 209964  6180 ?        Sl   Jul11   0:35 /usr/lib/indica
ulti    2431  0.0  0.1 311128  4096 ?        Sl   Jul11   0:00 /usr/lib/indica
ulti    2460  0.0  0.0 159216  3016 ?        Sl   Jul11   0:01 /usr/lib/geoclu
ulti    2466  0.0  0.0  56220  2008 ?        S    Jul11   0:00 /usr/lib/gvfs/g
ulti    2491  0.0  0.2 237108  7964 ?        S    Jul11   0:11 /usr/bin/python
ulti    2511  0.1  0.5 431804 22796 ?        Sl   Jul11   2:35 xchat
ulti    2513  0.0  0.2 225192 10000 ?        S    Jul11   0:07 /usr/lib/bamf/b
ulti    2517  0.0  0.3 368132 12532 ?        Sl   Jul11   0:44 /usr/bin/python
ulti    2555  0.3  0.2 291168  7864 ?        Sl   Jul11   5:24 skype
ulti    2556  0.0  0.2 322488  9860 ?        Sl   Jul11   0:01 update-notifier
ulti    2628  0.0  0.3 334148 15260 ?        Dl   Jul11   0:07 gnome-terminal
ulti    2636  0.0  0.0  14612   764 ?        S    Jul11   0:00 gnome-pty-helpe
ulti    6237  0.5  2.1 742192 81440 ?        SLl  Jul11   5:56 /opt/google/chr
ulti    6242  0.0  0.0 238432  3284 ?        S    Jul11   0:11 /opt/google/chr
ulti    6244  0.0  0.1 274712  5940 ?        S    Jul11   0:00 /opt/google/chr
ulti    6267  0.1  1.6 958724 65380 ?        SNl  Jul11   1:49 /opt/google/chr
ulti    6275  0.0  0.3 869444 13328 ?        Sl   Jul11   0:06 /opt/google/chr
ulti    6303  0.0  0.3 869440 13668 ?        Sl   Jul11   0:07 /opt/google/chr
ulti    6342  0.0  0.4 870532 15612 ?        Sl   Jul11   0:08 /opt/google/chr
ulti    6347  0.0  0.3 869444 13268 ?        Sl   Jul11   0:06 /opt/google/chr
ulti    6358  1.1  1.4 1003268 54604 ?       Sl   Jul11  12:00 python /usr/bin
ulti    7642  0.0  0.1 271220  7344 ?        S    Jul11   0:00 /usr/lib/gvfs/g
ulti    9719  0.0  0.1  28516  5580 pts/1    Ss   Jul11   0:00 bash
root     10577  0.0  0.0      0     0 ?        S    08:15   0:00 [migration/1]
root     10579  0.0  0.0      0     0 ?        S    08:15   0:00 [ksoftirqd/1]
root     10580  0.0  0.0      0     0 ?        S    08:15   0:00 [migration/2]
root     10582  0.0  0.0      0     0 ?        S    08:15   0:00 [ksoftirqd/2]
root     10583  0.0  0.0      0     0 ?        S    08:15   0:00 [migration/3]
root     10585  0.0  0.0      0     0 ?        S    08:15   0:00 [ksoftirqd/3]
root     10613  0.0  0.0      0     0 ?        S<   08:15   0:00 [hci0]
root     10638  0.0  0.0      0     0 ?        S    08:15   0:00 [mmcqd/0]
root     10894  0.0  0.0   7084   820 ?        S    08:15   0:00 /sbin/dhclient
postfix  10995  0.0  0.0  39480   928 ?        S    08:15   0:00 qmgr -l -t fifo
root     11013  0.0  0.0  15664  1152 ?        Ss   08:16   0:00 /sbin/mount.ntf
ulti   11339  0.0  0.3 262796 13452 ?        Sl   08:31   0:01 /opt/google/chr
ulti   12488  3.2  2.9 1044824 114420 ?      Sl   09:33  10:16 python /usr/bin
ulti   12923  0.0  0.0 287192  2552 ?        S<sl 09:53   0:04 /usr/bin/pulsea
ulti   12929  0.0  0.0 181372  3096 ?        Sl   09:53   0:00 /usr/lib/pulsea
root     15585  0.0  0.0  84056  3488 ?        S    11:16   0:00 /usr/bin/python
ulti   15756  0.0  0.0  71016  3080 ?        S    11:23   0:00 /usr/lib/gvfs/g
root     15952  0.0  0.0  73200  2764 ?        S    11:25   0:00 /usr/bin/python
ulti   15998  0.0  0.0      0     0 ?        Z    11:25   0:00 [sh] <defunct>
root     16013  0.0  0.0      0     0 ?        S    11:26   0:01 [kworker/1:1]
root     16672  0.0  0.0      0     0 ?        S    11:33   0:01 [kworker/u:0]
root     16697  0.0  0.0      0     0 ?        S    11:33   0:02 [kworker/2:1]
ulti   16937  0.0  0.0  42516  3556 pts/1    S+   11:36   0:02 ssh -2 -C -D 80
root     17235  0.0  0.0  21532   684 ?        S<   11:46   0:00 udevd --daemon
root     17236  0.0  0.0  21532   640 ?        S<   11:46   0:00 udevd --daemon
root     17428  0.0  0.0      0     0 ?        S    11:57   0:01 [kworker/u:2]
postfix  18676  0.0  0.0  39428  1372 ?        S    13:15   0:00 pickup -l -t fi
ulti   19703  0.0  0.1  28516  5844 pts/0    Ss   14:04   0:00 bash
root     19838  0.0  0.0  23252  1644 ?        Ss   14:05   0:00 /usr/sbin/bluet
root     20081  0.0  0.0      0     0 ?        S    14:09   0:00 [kworker/3:0]
root     20269  0.0  0.0      0     0 ?        S    14:14   0:00 [kworker/2:2]
root     20322  0.0  0.0      0     0 ?        S    14:15   0:00 [kworker/1:2]
root     20639  0.0  0.0      0     0 ?        S    14:26   0:00 [kworker/3:1]
root     20711  0.0  0.0      0     0 ?        S    14:30   0:00 [kworker/0:1]
root     20805  0.0  0.0      0     0 ?        S    14:33   0:00 [kworker/u:3]
root     20861  0.0  0.0      0     0 ?        S    14:35   0:00 [kworker/0:0]
root     21027  0.0  0.0      0     0 ?        S    14:41   0:00 [kworker/0:2]
ulti   21098  2.7  1.0 893504 39720 ?        SNl  14:44   0:01 /opt/google/chr
ulti   21116  2.1  0.6 381512 24504 ?        Sl   14:45   0:01 geany
ulti   21120  0.0  0.0  14612   828 ?        S    14:45   0:00 gnome-pty-helpe
ulti   21121  0.5  0.1  28504  5812 pts/2    Ss+  14:45   0:00 /bin/bash
ulti   21236  7.1  1.0 895512 41708 ?        Sl   14:45   0:01 /opt/google/chr
ulti   21246  0.0  0.0  21932  1400 pts/0    R+   14:46   0:00 ps -aux

vmstats after swapiness is set 10

procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa
 2  0 1458588 119320   2292 2748584    1   13    32    25   16  192  6  2 90  2

Why is the virtual memory usage so high? That's way higher than what both my swap and my memory can offer

Why is the virtual memory usage so high? That's way higher than what both my swap and my memory can offer.

smap info: These are long

  • Chrome Memory from smaps - ~ 930MB VIRT
  • Emesene memory from smaps - ~ 900MB VIRT

Update: Here's recently an out of memory event (I turned swap off at this point, also the cached memory is taking up round 2.5GB at the point, and only ~1GB of physical memory is used, so technically I have another 2.5GB to work with due to the supposed taking back of the cache by the kernel):

Syslog event showing the supposed "out of memory event"

Also a page showing my exact problem: http://raj2796.wordpress.com/2009/11/09/reducing-cached-memory-usage-linux-high-memory-usage-diagnosing-and-troubleshooting-on-vmware-and-out-of-memory-oom-killer-problem-and-solution/


How do I configure swappiness?

The Linux kernel provides a tweakable set ting that controls how often the swap file is used, called swappiness

A swappiness setting of zero means that the disk will be avoided unless absolutely necessary (you run out of memory), while a swappiness setting of 100 means that programs will be swapped to disk almost instantly.

Ubuntu system comes with a default of 60, meaning that the swap file will be used fairly often if the memory usage is around half of my RAM. You can check your own system's swappiness value by running:

one@onezero:~$ cat /proc/sys/vm/swappiness
60

As I have 4 GB of RAM, so I'd like to turn that down to 10 or 15. The swap file will then only be used when my RAM usage is around 80 or 90 percent. To change the system swappiness value, open /etc/sysctl.conf as root. Then, change or add this line to the file:

vm.swappiness = 10

Reboot for the change to take effect

You can also change the value while your system is still running

sysctl vm.swappiness=10

you can also clear your swap by running swapoff -a and then swapon -a as root instead of rebooting to achieve the same effect.

To calculate your swap Formula

free -m (total) / 100 = A

A * 10

root@onezero:/home/one# free -m
             total       used       free     shared    buffers     cached
Mem:          3950       2262       1687          0        407        952
-/+ buffers/cache:        903       3047
Swap:         1953          0       1953

so total is 3950 / 100 = 39.5 * 10 = 395

so what it mean is that when 10 % 395 MB of ram left then it start using swapiness


Help . Ubuntu . Swap

What is swappiness

The swappiness parameter controls the tendency of the kernel to move processes out of physical memory and onto the swap disk. Because disks are much slower than RAM, this can lead to slower response times for system and applications if processes are too aggressively moved out of memory.

. swappiness can have a value of between 0 and 100

. swappiness=0 tells the kernel to avoid swapping processes out of physical memory for as long as possible

. swappiness=100 tells the kernel to aggressively swap processes out of physical memory and move them to swap cache

The default setting in Ubuntu is swappiness=60. Reducing the default value of swappiness will probably improve overall performance for a typical Ubuntu desktop installation. A value of swappiness=10 is recommended, but feel free to experiment.


Started Using swap at 91%

enter image description here As i have configured my system & vm to make use of ram at 90 % . At 90 % there was no swapping

after that i opened some application like Firefox & Shutter , its start swapping because of ram usage is above 90 %


I found this link Help.ubuntu.com Community: Swap FAQ. The part about swapiness stands out as a point to check. To check the value from a terminal type this in.

cat /proc/sys/vm/swappiness

Default desktop version is 60 which mine is. A server is 10. The higher the value the more aggressive swap is used. The help FAQ explains how to adjust the value.

I have 4G of RAM and swap, like your system, and have never noticed my swap partition used.