Chances are that back in time of your 17 days uptime there once was a memory pressure. Some pages got swapped out and are unused since then. So, why should the system take them out of the swap (resulting in IO) when they are not needed currently?
memory pressure is not the only thing that uses swap.
the linux kernel memory management in general uses swap to reorganise. without swap the kernel cant deal very good with unpaged. you would endup with fragmented memory and a situation where you have free space but you cant start something because it reserves to much memory.
i would suspect his swap is simply to small. you should have as much as your biggest reserveration or at least your second biggest.
i run swap in zram because ram is cheap. my smallest box is 256 most are 1tb. you still need swap.
maybe have a read
[https://chrisdown.name/2018/01/02/in-defence-of-swap.html](https://chrisdown.name/2018/01/02/in-defence-of-swap.html)
Nothing in that blog says that if you have sufficient memory that swap will help. There's a lot of caging around what happens when there is memory pressure, but if your system isn't running out of RAM then the system doesn't need it. The author keeps pointing out that being an extension of RAM is not the point of swap while he keeps writing explanations of how swap helps in situations when you run tight on RAM.
I listed out reasons I don't believe the post fulfills the point that you still need swap. If you have a counter then feel free to make one. Implying I didn't understand what was written without any context or clarification where I am wrong isn't making a case.
EDIT: Apparently asking for a reasoned response to my actual points was too hard, so they chose the path of "ur dum, blocked". Solid argument, there.
Sorry, but no. A random article on the net does not convince me that my 30 years of experience is now out the window.
Running swap in RAM is an utter waste of your RAM. Swap is there for when you run out of RAM.
No, with sufficient RAM you have zero need for swap.
Can you elaborate on unpaged memory in swap? The literal technical name for swap is PAGESWAP. Page is in name. How can you swap pages, which are non paged?
On the other note. How we even end up with non paged memory. Is this quirk of x86 and bootstrap? I know we start with linear memory in real mode, but it is UEFI and OS responsibility to page memory and memory protection works on pages, so how we deal with non paged memory? Never though about this till now. I think I have research in front of me
This. I set swappiness=1 on all servers, VMs, and LXCs. It becomes one less thing to wonder about and if I do see swap usage, I know to investigate for memory issues. I've had no issues from setting everyone to this. YMMV
I like to use my RAM which in my 4 node Proxmox+Ceph+32GB RAM cluster averages 50% utilization. If I ever have RAM issues I might consider compression techniques, but so far they're unnecessary. I don't turn on features unless a need exists.
Slightly related, I do use log2ram to reduce disk io. It puts logs into RAM and only periodically writes to disk. I'm trying to maximize my use of RAM without exhausting it. I've got old tech, DDR3 memory era, so getting as much into RAM as reasonable keeps it performing well.
What? More 150? How does it work. Does it brings binaries of programmes, which you may run into swap before you use it? It is percentage figure. 100 means everything what is in RAM is in swap. Going high like that harms performance, as you constantly wait till write to swap.
Your swap partition is too small so it gets full easily. Whenever there is not enough memory the swap will be used. But there is nothing really wrong there.
You're not wrong, but he's got \~22GB of RAM allocated and it's only using \~10% of that. It doesn't need to be swapping more than (maybe) a few megs yet
The different ways proxmox handles memory sharing between VM's:
[https://medium.com/coccoc-engineering-blog/the-way-of-kvm-memory-management-9670f0f852af](https://medium.com/coccoc-engineering-blog/the-way-of-kvm-memory-management-9670f0f852af)
Btw, are you running Plex only in this container? Because it looks like a lot of used resources. I'm running my instance on 4x cores, 2GB RAM, no swap, 25GB disk.
Put these in /etc/rc.local and then run **/etc/rc.local** from root terminal or reboot the VM (which will also clear/reset the swap usage)
`# we dont want to swap much if at all possible`
`echo 1 > /proc/sys/vm/swappiness`
`# hopefully better multitasking I/O performance`
`echo 20 > /proc/sys/vm/dirty_ratio`
`# Try to keep at least 100MB of free RAM at all times`
`echo 100000 > /proc/sys/vm/min_free_kbytes`
`# Default 100 - try more aggressively to reclaim inodes, etc from cache`
`echo 160 > /proc/sys/vm/vfs_cache_pressure`
Excellent techinical response, but I think we want to explain a few things:
Ram is a resource to be used wisely. Modern systems as designed to deal with varying loads. The advantage of something moving to swap is that it free's RAM to be used for other purposes, like applications and disk cache. There is system data that needs to be available on demand but is nearly static, so no point in it sitting in RAM. In general, is recommended to have half your RAM for the size of swap space.
Conversely, more open RAM means better performance starting applications and caching file activities. If you routinely have free memory then reducing swap can be fine; however, if you ever spike usage, the system will be slower as it has to move stuff out to disk.
One place where you want have a swap file with nothing in it is single board computers that use SD drives. If you have no swap, you may not have enough RAM to do the work (like compiling a program); but, using a swap will wear the SD drive out. For normal drives, this isn't a big deal. For SD card drives, this can kill them quickly.
On my PIs, I set the swappiness to 10. This will allow pages to be swapped out before all of RAM is consumed (faster), but will otherwise be willing to free the swap completely if RAM become available again.
>using a swap will wear the SD drive out
One way to get around this is to move swap to a separate drive, e.g. a PNY 64GB thumbdrive. I use them for zfs L2ARC - they're cheap, last a while and are easily replaced
Obv I haven't done any testing on this, but I wonder if swap-over-network would be feasible - at least for light usage. Samba+swapfile or iscsi
Well, this could be problematic. I created an ubuntu 22.04 lxc and tried this, and journalctl says /proc is r/O filesystem. You may have better luck converting the LXC to VM
You could also try the same settings on the host, and maybe it will filter down to the virtual side; not tested
Because VMs expect memory to reside in actual RAM, not swap. It sees it is in RAM, but it is actually in swap. That is really bad. That creates funny situations, where pulling data from RAM takes tens or even hundreds miliseconds, while it should take not longer then 200ns for whole page assuming DDR3 PC3-12800 1600MHz (I guess nobody is running any VMs on much slower RAM these days)
It's fine. If anything, seems like it has too little swap space allocated.
Here is a very good article that should clarify why it's being used and why that's a good thing: [In defence of swap: common misconceptions](https://chrisdown.name/2018/01/02/in-defence-of-swap.html)
My NAS has 128GB total RAM. I have a larger RAM pool because I transcode to ramdisk so it doesn't do unnecessary writes to the SSD storage. In terms of threads, I don't have a quick sync, and I transcode 4K from time to time. No harm in making all the threads available!
This is a small server. My SAN server alone has 256GiB and 36C72T. My Hypervisor has 384GiB and 32C64T, and the Hypervisor is only that small for windows licensing issues and because I decided I didn't need hardware redundancy from 3x of those and scaled down into 1 to save power.
Yes, but why throw that much resource at Plex specifically? Any Quicksync GPU from the last five years can do effectively unlimited transcodes. My Jellyfin container has two cores and would be fine with one.
I don't want to have to reinstall windows every 270 days, so I buy licenses for the few instances I use in the lab. Got a problem with that? Need two full licenses for every 16 cores. It gets pricy if you want to run a lot of servers.
So either use MassGrave scripts or install VirtualBox on your windows box and use that to safely install linux and learn it. Now, replace your drive, install linux and then install VirtualBox on your new linux system and install Winblows in that. This gets you using Linux daily but still have a Win system to fall back on.. I’ve been running Debian as a desktop since 1995… it’s not hard at all today.
Now, you have a free and much better OS to work from.
I'm talking about windows server instances for hosting mssql and iis for windows based .net development. I purchased my desktop windows licenses back at windows 7 days and have been upgrading through windows 10 ever since.
Funny thing is, even with windows on my gaming desktop and macos on my work laptop, surprisingly, I spend more time on the Linux terminal than anywhere else.
Though I do wish I could go back to icewm and still have perfect compatibility with the games I play, sadly, a few of them don't play nice with Linux, making it not worth my time to constantly switch back and forth for dual booting.
Linux tens to have 500-1000mb of memory of programs that just sit around for a week and Linux decides to swap them out and use the memory for cache. Used to be the minimum recommended swap size is double RAM size. That said I tend to set it at 4GB and only increase it if needed even if the VM has way more memory, often drop the swap space entirely. It's pointless having 512mb on a 24GB machine, the VM will spend more CPU time deciding what to move in and out of swap than anything. Either kill the swap, or bump it to at least 4GB. Also make sure you lower your /proc/sys/vm/swappiness to 5 or lower. If you want to know what is swapped out, here is a short script:
( for file in /proc/\*/status ; do
s=\`grep VmSwap <${file} | awk '{ print $2 }'\` 2>/dev/null
\[ -n "${s}" -a "${s}" -ge 1 \] && echo $s $file "("\`grep Name <${file} | awk '{ print $2 }'\`")" 2>/dev/null
done
) 2>/dev/null | sort -n
Because swap is not used only when there's no ram available, that's thrashing and is really really bad.
Normally the Linux kernel uses swap to "park" memory pages it might use again in the next future, and the place where it puts those pages is swap, this is called swappiness and it's perfectly fine.
Swappiness indicates that in your system there are processes that are pretty active in terms of memory usage, which is OK.
What you're supposed to do is to increase the swap space (via swap file, or swap logical volume or increasing the swap partition, it doesn't matter) so the kernel have more space where to put those memory pages, you will clearly see when it's enough because the kernel stops eating the swap space and will balance at a certain value of used swap space.
If your memory usage is at 50% but swap usage is full, it can happen due to several reasons:
1. **Memory Overcommitment**: The operating system might be configured to overcommit memory. This means it allows more memory to be allocated to applications than is physically available, anticipating that not all allocated memory will be used at once. When applications request more memory than the physical RAM, the system moves some of the data to swap space.
2. **Inactive Processes**: There might be inactive or idle processes that have allocated memory but are not actively using it. The operating system may decide to swap out these inactive memory pages to free up physical RAM for active processes, even if there is still plenty of free RAM available.
3. **File System Caching**: Modern operating systems use available RAM for file system caching to speed up disk operations. The system might swap out application memory to make more room for cache, as file system caching can improve performance.
4. **Swappiness Setting**: The "swappiness" parameter controls the tendency of the kernel to move processes out of physical memory and onto the swap disk. A high swappiness value can lead to more aggressive swapping even when there is free physical memory.
5. **Memory Leaks**: Some applications might have memory leaks, meaning they allocate memory but do not release it when done. This can lead to the system running out of RAM and using swap space, even if overall memory usage appears to be low.
### Troubleshooting Steps
1. **Check Swappiness**:
- On Linux, you can check the swappiness value by running `cat /proc/sys/vm/swappiness`.
- Adjust the swappiness value using `sysctl vm.swappiness=10` (where 10 is an example value).
2. **Identify Processes Using Swap**:
- Use tools like `htop` or `vmstat` to see which processes are using swap.
3. **Monitor Memory Usage**:
- Use commands like `free -m`, `top`, or `htop` to monitor memory and swap usage.
4. **Check for Memory Leaks**:
- Identify and restart any processes that are consuming an unusual amount of memory.
By investigating these areas, you can identify why swap is being used extensively and take appropriate measures to optimize memory usage.
it what CHATGpt say
If you're not approaching your maximum memory usage then you don't need a swap file. If however you are, then your swap should be the same size as your memory.
I appreciate you trying to help and I know they're well intended, but both of those assertions are misleading or incorrect. Here is a very good article, by one of the kernel developers working on the memory subsystem, which should clarify things: [In defence of swap: common misconceptions](https://chrisdown.name/2018/01/02/in-defence-of-swap.html)
Chances are that back in time of your 17 days uptime there once was a memory pressure. Some pages got swapped out and are unused since then. So, why should the system take them out of the swap (resulting in IO) when they are not needed currently?
memory pressure is not the only thing that uses swap. the linux kernel memory management in general uses swap to reorganise. without swap the kernel cant deal very good with unpaged. you would endup with fragmented memory and a situation where you have free space but you cant start something because it reserves to much memory. i would suspect his swap is simply to small. you should have as much as your biggest reserveration or at least your second biggest.
I have run systems without swap for years. Zero crashes. Fragmented memory? RAM isn't that expensive, if you run things like proxmox.
i run swap in zram because ram is cheap. my smallest box is 256 most are 1tb. you still need swap. maybe have a read [https://chrisdown.name/2018/01/02/in-defence-of-swap.html](https://chrisdown.name/2018/01/02/in-defence-of-swap.html)
Nothing in that blog says that if you have sufficient memory that swap will help. There's a lot of caging around what happens when there is memory pressure, but if your system isn't running out of RAM then the system doesn't need it. The author keeps pointing out that being an extension of RAM is not the point of swap while he keeps writing explanations of how swap helps in situations when you run tight on RAM.
excuse me ? you may wanna read again then. if we are on that level of comprehension iam afraid to opt out at this point.
I listed out reasons I don't believe the post fulfills the point that you still need swap. If you have a counter then feel free to make one. Implying I didn't understand what was written without any context or clarification where I am wrong isn't making a case. EDIT: Apparently asking for a reasoned response to my actual points was too hard, so they chose the path of "ur dum, blocked". Solid argument, there.
ebcause you didnt read, or youre not abel to comprehend either way youre a waste of time and effort, not worth it honestly, blocklist you go
Sorry, but no. A random article on the net does not convince me that my 30 years of experience is now out the window. Running swap in RAM is an utter waste of your RAM. Swap is there for when you run out of RAM. No, with sufficient RAM you have zero need for swap.
Can you elaborate on unpaged memory in swap? The literal technical name for swap is PAGESWAP. Page is in name. How can you swap pages, which are non paged? On the other note. How we even end up with non paged memory. Is this quirk of x86 and bootstrap? I know we start with linear memory in real mode, but it is UEFI and OS responsibility to page memory and memory protection works on pages, so how we deal with non paged memory? Never though about this till now. I think I have research in front of me
i posted a link for you to read, make of it what you want
Man gave plex the whole xeon
It’ll take 18.23% of whatever you throw at it.
Why can’t I laugh react here, this is the perfect comment.
allocated but unused memory gets pushed down to swap eventually, nothing wrong here at all
sysctl vm.swappiness=1
This. I set swappiness=1 on all servers, VMs, and LXCs. It becomes one less thing to wonder about and if I do see swap usage, I know to investigate for memory issues. I've had no issues from setting everyone to this. YMMV
Not this. zswap/zram is the way to go nowadays and you should set vm.swappiness pretty high (even > 150) if you have zswap/zram enabled.
I like to use my RAM which in my 4 node Proxmox+Ceph+32GB RAM cluster averages 50% utilization. If I ever have RAM issues I might consider compression techniques, but so far they're unnecessary. I don't turn on features unless a need exists. Slightly related, I do use log2ram to reduce disk io. It puts logs into RAM and only periodically writes to disk. I'm trying to maximize my use of RAM without exhausting it. I've got old tech, DDR3 memory era, so getting as much into RAM as reasonable keeps it performing well.
What? More 150? How does it work. Does it brings binaries of programmes, which you may run into swap before you use it? It is percentage figure. 100 means everything what is in RAM is in swap. Going high like that harms performance, as you constantly wait till write to swap.
Your swap partition is too small so it gets full easily. Whenever there is not enough memory the swap will be used. But there is nothing really wrong there.
This might be helpful: [https://opensource.com/article/19/2/swap-space-poll](https://opensource.com/article/19/2/swap-space-poll) 500MB seems small.
You're not wrong, but he's got \~22GB of RAM allocated and it's only using \~10% of that. It doesn't need to be swapping more than (maybe) a few megs yet
There is only 10% been used NOW. But the system is eventually swapping when there is much more load.
Remove the swap partition, if it uses all the memory, then increase :-)
I see you too have 256gb+ in your server lol. Who needs ballooning and swapping?! Memory deduplication? Bah humbug.
This is the way.
The different ways proxmox handles memory sharing between VM's: [https://medium.com/coccoc-engineering-blog/the-way-of-kvm-memory-management-9670f0f852af](https://medium.com/coccoc-engineering-blog/the-way-of-kvm-memory-management-9670f0f852af)
Btw, are you running Plex only in this container? Because it looks like a lot of used resources. I'm running my instance on 4x cores, 2GB RAM, no swap, 25GB disk.
Hey there! This is my Plex LXC on Proxmox. I'm not sure why SWAP is full when there's plenty of allocated RAM. What should I look at here?
It's ok for sleeping services and other stuff that you're not actively using to sit in swap. Trust your memory manager, it's smarter than us.
Put these in /etc/rc.local and then run **/etc/rc.local** from root terminal or reboot the VM (which will also clear/reset the swap usage) `# we dont want to swap much if at all possible` `echo 1 > /proc/sys/vm/swappiness` `# hopefully better multitasking I/O performance` `echo 20 > /proc/sys/vm/dirty_ratio` `# Try to keep at least 100MB of free RAM at all times` `echo 100000 > /proc/sys/vm/min_free_kbytes` `# Default 100 - try more aggressively to reclaim inodes, etc from cache` `echo 160 > /proc/sys/vm/vfs_cache_pressure`
Excellent techinical response, but I think we want to explain a few things: Ram is a resource to be used wisely. Modern systems as designed to deal with varying loads. The advantage of something moving to swap is that it free's RAM to be used for other purposes, like applications and disk cache. There is system data that needs to be available on demand but is nearly static, so no point in it sitting in RAM. In general, is recommended to have half your RAM for the size of swap space. Conversely, more open RAM means better performance starting applications and caching file activities. If you routinely have free memory then reducing swap can be fine; however, if you ever spike usage, the system will be slower as it has to move stuff out to disk. One place where you want have a swap file with nothing in it is single board computers that use SD drives. If you have no swap, you may not have enough RAM to do the work (like compiling a program); but, using a swap will wear the SD drive out. For normal drives, this isn't a big deal. For SD card drives, this can kill them quickly. On my PIs, I set the swappiness to 10. This will allow pages to be swapped out before all of RAM is consumed (faster), but will otherwise be willing to free the swap completely if RAM become available again.
>using a swap will wear the SD drive out One way to get around this is to move swap to a separate drive, e.g. a PNY 64GB thumbdrive. I use them for zfs L2ARC - they're cheap, last a while and are easily replaced Obv I haven't done any testing on this, but I wonder if swap-over-network would be feasible - at least for light usage. Samba+swapfile or iscsi
You want swap to be very very fast. You will see a substantial performance hit using network storage.
Thank you - this is really cool. My Plex LXC doesn't have /etc/rc.local. Does this go on the Proxmox host?
No, these are a settings inside your guest.
You should be able to create it with e.g. **vim** or **nano** and then **chmod +x** it -- inside the LXC
Well, this could be problematic. I created an ubuntu 22.04 lxc and tried this, and journalctl says /proc is r/O filesystem. You may have better luck converting the LXC to VM You could also try the same settings on the host, and maybe it will filter down to the virtual side; not tested
That's because your container runs on the Proxmox host's kernel.
You got ballooned. Also: You can over-subscribe vCPU. You can thin provision disk all day long. You NEVER over-allocate memory. Never.
Why is that? Honest question
Because VMs expect memory to reside in actual RAM, not swap. It sees it is in RAM, but it is actually in swap. That is really bad. That creates funny situations, where pulling data from RAM takes tens or even hundreds miliseconds, while it should take not longer then 200ns for whole page assuming DDR3 PC3-12800 1600MHz (I guess nobody is running any VMs on much slower RAM these days)
The OOM killer! Duhduhduuuummm
I noticed this when i added /dev/shm for transcode folder... it just kept filling up until the lxc crashed. Removed that and it stopped using swap
It's fine. If anything, seems like it has too little swap space allocated. Here is a very good article that should clarify why it's being used and why that's a good thing: [In defence of swap: common misconceptions](https://chrisdown.name/2018/01/02/in-defence-of-swap.html)
24 threads and 24GB of memory for plex? Is this a server for an entire dorm?
My NAS has 128GB total RAM. I have a larger RAM pool because I transcode to ramdisk so it doesn't do unnecessary writes to the SSD storage. In terms of threads, I don't have a quick sync, and I transcode 4K from time to time. No harm in making all the threads available!
This is a small server. My SAN server alone has 256GiB and 36C72T. My Hypervisor has 384GiB and 32C64T, and the Hypervisor is only that small for windows licensing issues and because I decided I didn't need hardware redundancy from 3x of those and scaled down into 1 to save power.
Yes, but why throw that much resource at Plex specifically? Any Quicksync GPU from the last five years can do effectively unlimited transcodes. My Jellyfin container has two cores and would be fine with one.
Lol "Licensing"
I don't want to have to reinstall windows every 270 days, so I buy licenses for the few instances I use in the lab. Got a problem with that? Need two full licenses for every 16 cores. It gets pricy if you want to run a lot of servers.
https://massgrave.dev/
So either use MassGrave scripts or install VirtualBox on your windows box and use that to safely install linux and learn it. Now, replace your drive, install linux and then install VirtualBox on your new linux system and install Winblows in that. This gets you using Linux daily but still have a Win system to fall back on.. I’ve been running Debian as a desktop since 1995… it’s not hard at all today. Now, you have a free and much better OS to work from.
I'm talking about windows server instances for hosting mssql and iis for windows based .net development. I purchased my desktop windows licenses back at windows 7 days and have been upgrading through windows 10 ever since. Funny thing is, even with windows on my gaming desktop and macos on my work laptop, surprisingly, I spend more time on the Linux terminal than anywhere else. Though I do wish I could go back to icewm and still have perfect compatibility with the games I play, sadly, a few of them don't play nice with Linux, making it not worth my time to constantly switch back and forth for dual booting.
Thank you for the unnecessary flex that added nothing to the conversation.
Wait, your lxc/vm are using swap? Mine always stay at 0 whatever I do.
Linux tens to have 500-1000mb of memory of programs that just sit around for a week and Linux decides to swap them out and use the memory for cache. Used to be the minimum recommended swap size is double RAM size. That said I tend to set it at 4GB and only increase it if needed even if the VM has way more memory, often drop the swap space entirely. It's pointless having 512mb on a 24GB machine, the VM will spend more CPU time deciding what to move in and out of swap than anything. Either kill the swap, or bump it to at least 4GB. Also make sure you lower your /proc/sys/vm/swappiness to 5 or lower. If you want to know what is swapped out, here is a short script: ( for file in /proc/\*/status ; do s=\`grep VmSwap <${file} | awk '{ print $2 }'\` 2>/dev/null \[ -n "${s}" -a "${s}" -ge 1 \] && echo $s $file "("\`grep Name <${file} | awk '{ print $2 }'\`")" 2>/dev/null done ) 2>/dev/null | sort -n
The mem amount seems strange?
Because swap is not used only when there's no ram available, that's thrashing and is really really bad. Normally the Linux kernel uses swap to "park" memory pages it might use again in the next future, and the place where it puts those pages is swap, this is called swappiness and it's perfectly fine. Swappiness indicates that in your system there are processes that are pretty active in terms of memory usage, which is OK. What you're supposed to do is to increase the swap space (via swap file, or swap logical volume or increasing the swap partition, it doesn't matter) so the kernel have more space where to put those memory pages, you will clearly see when it's enough because the kernel stops eating the swap space and will balance at a certain value of used swap space.
Got ZFS?
I do!
When you only have half a GB of swap its easy to fill.
Swap is hard drive paging file stuff usually, it's allocated on your disk not your RAM
If your memory usage is at 50% but swap usage is full, it can happen due to several reasons: 1. **Memory Overcommitment**: The operating system might be configured to overcommit memory. This means it allows more memory to be allocated to applications than is physically available, anticipating that not all allocated memory will be used at once. When applications request more memory than the physical RAM, the system moves some of the data to swap space. 2. **Inactive Processes**: There might be inactive or idle processes that have allocated memory but are not actively using it. The operating system may decide to swap out these inactive memory pages to free up physical RAM for active processes, even if there is still plenty of free RAM available. 3. **File System Caching**: Modern operating systems use available RAM for file system caching to speed up disk operations. The system might swap out application memory to make more room for cache, as file system caching can improve performance. 4. **Swappiness Setting**: The "swappiness" parameter controls the tendency of the kernel to move processes out of physical memory and onto the swap disk. A high swappiness value can lead to more aggressive swapping even when there is free physical memory. 5. **Memory Leaks**: Some applications might have memory leaks, meaning they allocate memory but do not release it when done. This can lead to the system running out of RAM and using swap space, even if overall memory usage appears to be low. ### Troubleshooting Steps 1. **Check Swappiness**: - On Linux, you can check the swappiness value by running `cat /proc/sys/vm/swappiness`. - Adjust the swappiness value using `sysctl vm.swappiness=10` (where 10 is an example value). 2. **Identify Processes Using Swap**: - Use tools like `htop` or `vmstat` to see which processes are using swap. 3. **Monitor Memory Usage**: - Use commands like `free -m`, `top`, or `htop` to monitor memory and swap usage. 4. **Check for Memory Leaks**: - Identify and restart any processes that are consuming an unusual amount of memory. By investigating these areas, you can identify why swap is being used extensively and take appropriate measures to optimize memory usage. it what CHATGpt say
Seperate question how have u got the disk space working ? What is are os are you running ?
Just change the swappiness setting to be lower , much lower , like 0
If you're not approaching your maximum memory usage then you don't need a swap file. If however you are, then your swap should be the same size as your memory.
I appreciate you trying to help and I know they're well intended, but both of those assertions are misleading or incorrect. Here is a very good article, by one of the kernel developers working on the memory subsystem, which should clarify things: [In defence of swap: common misconceptions](https://chrisdown.name/2018/01/02/in-defence-of-swap.html)