# Swap usage when plenty free memory

**URL:** <https://forums.rockylinux.org/t/swap-usage-when-plenty-free-memory/11052>\
**Category:** Rocky Linux Help & Support\
**Created:** [August 18, 2023, 7:05am UTC](https://forums.rockylinux.org/t/swap-usage-when-plenty-free-memory/11052 "2023-08-18T07:05:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bagafoot](https://avatars.discourse-cdn.com/v4/letter/b/13edae/32.png) [@bagafoot](https://forums.rockylinux.org/u/bagafoot)\
**Post date:** [August 18, 2023, 7:05am UTC](https://forums.rockylinux.org/t/swap-usage-when-plenty-free-memory/11052/1 "2023-08-18T07:05:45Z")

</div>

Hello, I got bare metal Rocky Linux 8 server that has 1 TB RAM.  
This server running as Postgresql Master node.  
Although 1 tb ram, many process using swap space especially postgres processes.  
When I check free memory it has almost x3 of swap space. I moved pages from swap to memory but after little time it occured again.  
How to check why it insist on using swap?

os-release  
NAME=“Rocky Linux”  
VERSION=“8.7 (Green Obsidian)”  
ID=“rocky”  
ID\_LIKE=“rhel centos fedora”  
VERSION\_ID=“8.7”  
PLATFORM\_ID=“platform:el8”  
PRETTY\_NAME=“Rocky Linux 8.7 (Green Obsidian)”  
ANSI\_COLOR=“0;32”  
LOGO=“fedora-logo-icon”  
CPE\_NAME=“cpe:/o:rocky:rocky:8:GA”  
HOME\_URL=“[https://rockylinux.org/](https://rockylinux.org/)”  
BUG\_REPORT\_URL=“[https://bugs.rockylinux.org/](https://bugs.rockylinux.org/)”  
ROCKY\_SUPPORT\_PRODUCT=“Rocky-Linux-8”  
ROCKY\_SUPPORT\_PRODUCT\_VERSION=“8.7”  
REDHAT\_SUPPORT\_PRODUCT=“Rocky Linux”  
REDHAT\_SUPPORT\_PRODUCT\_VERSION=“8.7”

kernel version  
6.1.10-1.el8.elrepo.x86\_64

swappiness  
vm.swappiness = 0  
vm.overcommit\_memory = 2  
vm.overcommit\_ratio = 80

free -mh  
total used free shared buff/cache available  
Mem: 1.0Ti 291Gi 7.7Gi 832Mi 708Gi 709Gi  
Swap: 4.0Gi 823Mi 3.2Gi

 ![swap](https://us1.discourse-cdn.com/flex020/uploads/rockylinux/original/2X/9/9267ca175640143795f759fcbd7e998941cba60f.png)

---

<div class="post-metadata">

**Author:** ![jlehtone](https://avatars.discourse-cdn.com/v4/letter/j/e9a140/32.png) [@jlehtone](https://forums.rockylinux.org/u/jlehtone)\
**Post date:** [August 18, 2023, 7:16am UTC](https://forums.rockylinux.org/t/swap-usage-when-plenty-free-memory/11052/2 "2023-08-18T07:16:30Z")

</div>

Does the Rocky kernel do the same, i.e. is this “feature” in all kernels or only in that upstream version?

What if you remove swap completely? Running out of RAM does not seem an immediate threat.  
That is, are some processes adamant to explicitly use swap regardless of status of RAM?

---

<div class="post-metadata">

**Author:** ![bagafoot](https://avatars.discourse-cdn.com/v4/letter/b/13edae/32.png) [@bagafoot](https://forums.rockylinux.org/u/bagafoot)\
**Post date:** [August 18, 2023, 7:27am UTC](https://forums.rockylinux.org/t/swap-usage-when-plenty-free-memory/11052/3 "2023-08-18T07:27:45Z")

</div>

I didn’t try it boot on default kernel version (kernel-4.18.0-425.3.1.el8.x86\_64)  
It is prod server.  
Yes I should try in appropriate time.

_That is, are some processes adamant to explicitly use swap regardless of status of RAM?_  
I dont think so because it is typical postgres process and just in this server using swap, I got many  
postgres servers that swap is totally free

---

<div class="post-metadata">

**Author:** ![dali](https://avatars.discourse-cdn.com/v4/letter/d/c68b51/32.png) [@dali](https://forums.rockylinux.org/u/dali)\
**Post date:** [August 19, 2023, 5:17pm UTC](https://forums.rockylinux.org/t/swap-usage-when-plenty-free-memory/11052/5 "2023-08-19T17:17:45Z")

</div>

Try activating cgroups v2, see [Premature swapping with swappiness=0 while there is still plenty of pagecache to be reclaimed - Red Hat Customer Portal](https://access.redhat.com/solutions/6785021).
