LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 05-22-2018, 09:23 AM   #1
joemon83
Member
 
Registered: Jan 2009
Posts: 71

Rep: Reputation: 11
Freeing swap memory


Hi,
I have a generic doubt of swap space.
Once a process has been swapped out, will this actually be removed from swap other than when the process is killed ? Bcoz I read somewhere that even if the process is swapped in, the system still maintains it in swap to avoid the swapin swapouts in future. We have a server where the swap usage reaches almost 100% in 10 days after system is rebooted. But swapin-swapout is very less after this.
 
Old 05-22-2018, 10:33 AM   #2
Keruskerfuerst
Senior Member
 
Registered: Oct 2005
Location: Horgau, Germany
Distribution: Manjaro KDE, Win 10
Posts: 2,199

Rep: Reputation: 164Reputation: 164
Can you give hardware info about your server?

Maybe the size of RAM is not sufficient.
 
Old 05-22-2018, 07:10 PM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Tasks haven't been "swapped out" since the Linux 2 era - only annonomous memory is subject to swap.
Quote:
Originally Posted by joemon83 View Post
Once a process has been swapped out, will this actually be removed from swap other than when the process is killed ?
Eventually. Running the page-table queues is expensive if not required, so it is deferred where possible. If the pages are needed for another task, they are released immediately.
Quote:
Bcoz I read somewhere that even if the process is swapped in, the system still maintains it in swap to avoid the swapin swapouts in future.
Same comment applies - if required, they are released immediately. Likewise if the page in memory is altered.
Quote:
We have a server where the swap usage reaches almost 100% in 10 days after system is rebooted. But swapin-swapout is very less after this.
Maybe you have an application that acquires memory until it can get no more, then proceeds with that. Monitoring usage over time might give some hints.
 
Old 05-22-2018, 07:16 PM   #4
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,981

Rep: Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625
It may be possible to trace what is causing swap to fill up. The system ought to manage it but depending on how old the programs are they may simply try to use swap. A few thousand copies of some program may fill it.

I might be tempted to see what https://en.wikipedia.org/wiki/Swappiness changes may do.

Kind of suspect one of two issues. One that you do really need more swap or two that some memory leak causing it. Guess along that way some program is misbehaving or being caused to misbehave.

Last edited by jefro; 05-22-2018 at 07:17 PM.
 
Old 05-23-2018, 05:45 PM   #5
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
For another thread I was playing with "top" yesterday - it's easy to add a "Swap" column to see what is currently allocated. Perhaps set up a batch run after a boot with say a 10-20 minute interval to write to a file. That way you can see the increase occurring per task.
 
Old 05-24-2018, 12:11 AM   #6
joemon83
Member
 
Registered: Jan 2009
Posts: 71

Original Poster
Rep: Reputation: 11
Hi,
Its a long reply

System had 6G ram initially when the issue was reported.
Swap was reaching almost 100% in 1 to 2 weeks time. System still had 1G buffer/cache.
The problem here is that there is no single process occupying high memory.
If you run top and sort based on Memory or swap, you will find 5-6 processes using more than 10-15% of the total memory/swap.
This rules out the possibility of memory leak.
And another interesting thing is that this issue happens for multiple nodes in 2 different clusters (running almost same list of applications.)
This was a clear sign that system was running out of memory and swap.
So we increased memory from 6G to 8G hoping that this would solve the issue.
But it didn't.
swap memory usage still rose to more than 90% in 10 days.
The buffer/cache memory which previously used to be 1G, now became 3G
(The behavior was not same in all the nodes. For some nodes it didn't even go beyond 50%).

The only logical justification I could find is that system really needed more swap memory.
Bcoz what I understand is that processes/pages which were swapped out once, were never removed from swap memory.
Unless you manually clear it or the application is killed/stopped.
But somewhere I read that even if a process is killed, system won't really show this space as free bcoz linux uses Lazy memory management as removing page table entries frequently is an expensive process. Until some apps request for more memory.

Any more inputs appreciated.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Freeing Up Used Memory zoso Linux - Newbie 7 01-11-2005 09:44 PM
SWAP not freeing loonix Debian 2 12-28-2003 05:10 PM
Freeing swap LinFreak! Slackware 2 12-13-2003 08:48 AM
Freeing up Memory DigiCrime Linux - General 5 09-30-2003 07:25 AM
freeing up swap space on my linux system manmagic Linux - General 1 06-22-2001 07:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 02:57 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration