Swap file - More information

SYSTEM INFORMATION
OS type and version Ubuntu Linux 22.04.4
Webmin version 2.111
Usermin version 2.010
Virtualmin version 7.10.0
Theme version 21.10
Package updates 108 package updates are available

Background

  • I am a windows guy, so if I am wrong about what Linux can do here, just let me know :smile:
  • My Ubuntu is using a swap file and not a swap partition

the issue

When you click on the Virtual Memory icon on the dashboard

You are taken here to show the processes in memory, it does not show what is in RAM and what is in SWAP specifically. It does give a summary at the top though of the two technologies

Feature being requested

i will add this to github if it is a sensible idea

Is there anyway of getting what processes have been paged out to the swap file? i.e. changing Memory to Memory + RAM + Swap

image

This might help finding out what processes keep getting sent to swap.

additional

  • I know it is bad if you server is using swap as this indicate RAM has been exhausted

Well, not exactly. No, RAM has not been exhausted.

Swap space is used preemptively even when RAM is available. The idea is that swap space will be used to (temporarily) swap out some parts of the RAM so that it can be freed up for some short-term requirement.

You could put in your request on github but what will you do with the info you desire to have? You can tweak the swappiness even without the info.

See
vmstat -D and

Todo learn how swap works, maybe search ‘linux swapiness’ https://www.howtogeek.com/449691/what-is-swapiness-on-linux-and-how-to-change-it/
Then from that tailor your system to suit, tbf I don’t think this is anything webmin should dabble with, as every system is different and has different requirements but you can purge the swap file using

swapoff -a && swapon -a 

But tbf I would let the kernel manage it and just let the kernel do what it thinks best
Some will say purging the swap is bad practice and I also agree

thanks for the feedback.

From what you guys have said, then actually having this information is useful.

I assumed the swap was used as an emergency fallback, but you can configure the OS to actively use the swap file. Ubuntu default swapiness is 60.

it’s not going to swap out the complete process

Code pages. The pages store executable instructions of programs. Code pages contain machine code and have read-only permissions to prevent accidental changes. Processes that execute the same programs share code pages to optimize memory use.
Data pages. They hold non-executable data for programs, such as variables, constants, or data structures. Data pages are writeable, and programs freely modify the values when required. Processes do not share data pages.
Stack pages. Stack pages are dynamic and store stacks for function calls and local variables. The pages operate using the last-in-first-out (LIFO) principle and are crucial in managing function executions and program states.
Heap pages. The pages store dynamic memory allocation and deallocation from functions such as malloc() and free(). Heap pages store data with a predetermined size and lifetime. The data requires deallocation to prevent memory leaks.
File-backed pages. These pages are directly associated with specific files on the disk. They are crucial in memory-mapped files and directly connect virtual memory address space for a process. Changes to file-backed pages reflect on the original file, providing a convenient way to read and write file data.
Anonymous pages. Also known as private pages, anonymous pages are not associated with any particular files and are not tied to persistent storage. These pages hold data for dynamically allocated memory, such as variables and data created at runtime.
Shared memory pages. Shared memory pages hold shared data between multiple processes. The pages enable direct reading and writing from shared memory and enhance process synchronization.

so dependant on use the data pages may be written to swap and not the code pages or both, you need to find someone who codes the kernel to get a definitive answer, what I am saying there is you could have the data written to swap but the process is still in ram, in the past I have used the smem command to find out what was swapped out but soon lost interest as there is nothing you can really do about it
sample output from smem


note I have queried both a user and root here

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.