§ 028 · Linux

How to Identify Processes Using Swap Memory on Linux

Identifying which processes have pages swapped out of memory when troubleshooting performance issues on a Linux system is often helpful. Swapping can impact system performance, so knowing which processes are affected is important in diagnosing and resolving these issues.

Checking Swap Usage by Process

Linux provides detailed process information in the /proc directory. By leveraging this, you can extract each process’s swap memory usage with a simple bash command.

The Command

Run the following command in your terminal to display the amount of swap memory used per process:

Explanation

1. Iterating through /proc:

The command processes every status file under /proc, which contains metadata about each running process.

2. Extracting Relevant Information:

The awk command searches for lines containing VmSwap (swap usage in kilobytes) and Name (process name).

It prints the process name and its swap usage on the same line.

3. Sorting Results:

The sort command organizes the output numerically in descending order based on the second column (swap usage).

4. Filtering Results:

The head command filters the top 20 processes using swap

Sample Output

Here’s an example of what the output might look like:

Conclusion

The above command quickly identifies processes that are consuming swap memory and addresses potential performance bottlenecks. This lightweight, native approach is particularly useful for Linux administrators and developers seeking to optimize system performance without relying on additional tools.

 

Written by

Vinicius Grippa

Writes this blog. Mostly about databases. Boring on purpose.

More about me →

The floor is yours.

0 comments · Moderated · civil & on-topic

First comment appears here once approved. Questions, corrections, and counterpoints welcome — just no self-promotion.

Add a comment

Your email address is never published. * required

Subscribe · Posted when ready

A quiet, technical email about databases.

One post per send, corrections when I’m wrong, nothing else. No social-media cross-posts. No “what we learned.”

Unsubscribe with any reply