Score:1

SWAP usage too high after upgrading RAM

ru flag

I had upgraded the ram on my Ubuntu 20.04.1 LTS from 16 GB to 32 GB. Things seemed to had worked fine, i.e., the machine ran and cat /proc/meminfo showed 32 GB of ram. Today the machine seemed considerably slower, so I checked again and this is what top looked like:

top - 14:00:38 up 17 days, 18:39,  1 user,  load average: 2.75, 2.39, 2.28
Tasks: 510 total,   2 running, 507 sleeping,   0 stopped,   1 zombie
%Cpu(s): 11.6 us,  1.8 sy,  0.1 ni, 86.5 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
MiB Mem :  31954.0 total,   1612.3 free,  13689.8 used,  16652.0 buff/cache
MiB Swap:   2048.0 total,    368.6 free,   1679.4 used.  17463.2 avail Mem 

Why is only 1612.3 M free, when the total is 31954 and 13689 is used? Do I need to reinstall Ubuntu after upgrading the ram?

If it helps, here's the latest cat /proc/meminfo

MemTotal:       32720944 kB
MemFree:         1527484 kB
MemAvailable:   17764224 kB
Buffers:         1158432 kB
Cached:         15098500 kB
SwapCached:        42640 kB
Active:         17130404 kB
Inactive:       11875732 kB
Active(anon):   11796372 kB
Inactive(anon):  1297452 kB
Active(file):    5334032 kB
Inactive(file): 10578280 kB
Unevictable:         596 kB
Mlocked:             580 kB
SwapTotal:       2097148 kB
SwapFree:         377668 kB
Dirty:             18900 kB
Writeback:             0 kB
AnonPages:      12706816 kB
Mapped:          3533448 kB
Shmem:            353120 kB
KReclaimable:     796040 kB
Slab:            1239524 kB
SReclaimable:     796040 kB
SUnreclaim:       443484 kB
KernelStack:       31520 kB
PageTables:       107500 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:    18457620 kB
Committed_AS:   35499648 kB
VmallocTotal:   34359738367 kB
VmallocUsed:       92868 kB
VmallocChunk:          0 kB
Percpu:            17536 kB
HardwareCorrupted:     0 kB
AnonHugePages:     65536 kB
ShmemHugePages:        0 kB
ShmemPmdMapped:        0 kB
FileHugePages:         0 kB
FilePmdMapped:         0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
Hugetlb:               0 kB
DirectMap4k:    16035156 kB
DirectMap2M:    17354752 kB
DirectMap1G:     1048576 kB
vanadium avatar
cn flag
Use "top" to see which processes consume the memory.
Score:1
cn flag

Hope you're doing great.

You have 17.7GB in Available Memory.

Linux uses all the non used memory to optimize IO, so for buffers/cache, this doesn't mean that your system does not have available memory.

So you have: 32GB in total, free 1.6GB, used by apps 13.6GB and 16.6GB in buffers/cached. Most of the buffers/cache can be used by the system when needed. The memory that really can be used is the MemAvailable, which is displayed as 17.7GB.

Run commands like:

free -h

For more clarity.

I think your problem is you have the default Swappiness value, 60, so the swap will be started to be used when you reach approximately 60% of RAM memory in use.

You can check this value with:

$ sysctl vm.swappiness
vm.swappiness = 60

Using swap normally is slow, cause accessing the drives is much more slower.

In my cloud systems and workstations I don't use swap, and if I use for whatever reason I set swappiness to values 1 or 10.

To do it until you restart the computer you can set this Kernel parameter by doing:

sudo sysctl vm.swappiness=10

You can then disable swap and enable it again.

sudo swapoff

and reenable again

sudo swapon -a

Your computer will fly again. :)

Cheers

mondotofu avatar
cn flag
I have seen more "high memory utilization" in RedHat based distros, and far fewer in Debian (Ubuntu) ones. I think that you're really using that memory. You may want to follow top a bit more during a "typical" session on your machine and see whether certain programs are taking up more memory than before. I am speculating that "greedy" programs want to grab a certain percentage of your available memory and may not release it or clean up afterwards.
mondotofu avatar
cn flag
With RedHat based distros it often looks like less memory available because of how it caches it. This perception is less common in my Ubuntu installations. I think that you're really using that memory. You maty want to follow top a bit more during a "typical" session on your machine and see whether certain programs are taking up more memory than before. I am speculating that "greedy" programs want to grab a certain percentage of your available memory and may not release it or clean up afterwards. Also, close top when you don't need it.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.