Ubuntu – Swapfile size is 2G. What would be the best size to allocate to it

19.10swap

This is a followup question to my original question related to the Ubuntu 19.10 freeze where I had to restart the machine every time.

I looked up at my swapfile and it is of 2G size. I do have a 16G of RAM. But the memory that is being used by the swapfile is '0'. I don't understand what is going on with this.

$ swapon
        NAME      TYPE SIZE USED PRIO
        /swapfile file   2G   0B   -2
$ free    
              total        used        free      shared  buff/cache   available
    Mem:       16383568     2503164    11927228      477108     1953176    13073208
    Swap:       2097148           0     2097148

The following is the image. Can some one help me with this?

Update: The following are the version of the NVIDIA driver I have.

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 435.21       Driver Version: 435.21       CUDA Version: 10.1     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce RTX 2080    Off  | 00000000:08:00.0  On |                  N/A |
|  0%   49C    P8    17W / 225W |    394MiB /  7981MiB |      9%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0      1045      G   /usr/lib/xorg/Xorg                            24MiB |
|    0      1444      G   /usr/lib/xorg/Xorg                           101MiB |
|    0      1652      G   /usr/bin/gnome-shell                         206MiB |
|    0      6468      G   /usr/lib/firefox/firefox                       6MiB |
+-----------------------------------------------------------------------------+

Update 2: The following are the results of systcl vm.swappiness and grep -i swap /etc/fstab

~$ sysctl vm.swappiness
    vm.swappiness = 60
~$ grep -i swap /etc/fstab
    /swapfile                                 none            swap    sw              0       0

Update 3: Added the result for ls -al /usr/share/gnome-shell/extensions
– Did not have the folder extensions under /.local/share/gnome-shell

$ ls -al /usr/share/gnome-shell/extensions
total 20
drwxr-xr-x 5 root root 4096 Oct 17  2019 .
drwxr-xr-x 6 root root 4096 Nov 27 09:32 ..
drwxr-xr-x 2 root root 4096 Oct 17  2019 desktop-icons@csoriano
drwxr-xr-x 3 root root 4096 Oct 17  2019 ubuntu-appindicators@ubuntu.com
drwxr-xr-x 3 root root 4096 Oct 17  2019 ubuntu-dock@ubuntu.com

Update 3: Here I am attaching the drivers I am using for the NVidia. I have tried 435 but I kept on seeing some display issues with it. They come and go. They are something like this.

enter image description here

Now I tried the 430 in the drivers section. This seems to work fine so far. I have seen those out of order pixels but very rarely. What could be the reason for this? And I tried installinng the newly release 440 drivers for the nVidia but it kept on failing and therefore as a lost resort I had to move back to 430.

enter image description here

Best Answer

I would say to just leave it as is. The swap file is a file stored on your hard drive or SSD that is used as a place for inactive data in your RAM when your system is running low on RAM. Also, by the looks of it, your system isn't using the swap file at all. This is because you probably aren't using that much RAM, so your system doesn't need to use the swap file. However, you should keep it to give your system a buffer if it's running low on RAM, just in case you ever do something RAM intensive. Besides, resizing/deleting your swap file is kind of complicated, and is only necessary for very specific use cases.

Related Question