LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-09-2012, 12:26 AM   #1
vicky007aggrwal
Member
 
Registered: Aug 2012
Posts: 95

Rep: Reputation: Disabled
swap used up , even though RAM free


Hello Everyone.

can somebody will help me in understanding the swap memory concept.
As in my application i have seen that swap memory is getting used fully even when the Free space is available in RAM.
My understanding was swap wil be used only when there is RAM crunch issue..

Kindly suggest why space is used fully , any article,link will be of great help

My application setting
RAM- 10 G
SWAP 3 G
 
Old 08-09-2012, 12:56 AM   #2
kedarp
Member
 
Registered: Jul 2012
Distribution: Ubuntu
Posts: 197
Blog Entries: 3

Rep: Reputation: 23
Smile

First of all, how do yo know that your Swap space is being used?
Also mention your Distribution.
 
Old 08-09-2012, 01:08 AM   #3
vicky007aggrwal
Member
 
Registered: Aug 2012
Posts: 95

Original Poster
Rep: Reputation: Disabled
I checked the swap usage using free -g command



uname -a
Linux localhost.com 2.6.18-128.1.6 Mar 24 12:05 2009 x86_64 x86_64 x86_64 GNU/Linux


cat /etc/issue

linux64-5.3.2
 
Old 08-09-2012, 01:35 AM   #4
kedarp
Member
 
Registered: Jul 2012
Distribution: Ubuntu
Posts: 197
Blog Entries: 3

Rep: Reputation: 23
Red face

Use "free" with -m parameter and list the output here.
You should try the command "swapon -s", and also list the output.
For details, refer "man swapon".
As I studied, Swap is outside the control of the user and is managed by the kernel.
So you actually cannot find the solution. Your swap may be used only because your
system cannot use more RAM.

Last edited by kedarp; 08-09-2012 at 02:49 AM.
 
Old 08-09-2012, 03:35 AM   #5
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,133
Blog Entries: 2

Rep: Reputation: 4839Reputation: 4839Reputation: 4839Reputation: 4839Reputation: 4839Reputation: 4839Reputation: 4839Reputation: 4839Reputation: 4839Reputation: 4839Reputation: 4839
The Linux kernel usually swaps out some not RAM that is occupied by applications that are not used for a long time to use that RAM as cache to speed up the system. So even on systems with high amount of RAM you can sometimes see a few MB of used swap although there is plenty of RAM.
This is normal behavior, I wouldn't bother about that.
 
Old 08-09-2012, 03:47 AM   #6
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 15,721

Rep: Reputation: 2120Reputation: 2120Reputation: 2120Reputation: 2120Reputation: 2120Reputation: 2120Reputation: 2120Reputation: 2120Reputation: 2120Reputation: 2120Reputation: 2120
The OP did say (my emphasis)...
Quote:
Originally Posted by vicky007aggrwal View Post
As in my application i have seen that swap memory is getting used fully even when the Free space is available in RAM.
Post the contents of /proc/meminfo.
 
Old 08-09-2012, 04:01 AM   #7
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,133
Blog Entries: 2

Rep: Reputation: 4839Reputation: 4839Reputation: 4839Reputation: 4839Reputation: 4839Reputation: 4839Reputation: 4839Reputation: 4839Reputation: 4839Reputation: 4839Reputation: 4839
Sorry, seems that I have overlooked the "fully" part.
 
Old 08-09-2012, 05:27 PM   #8
jefro
Moderator
 
Registered: Mar 2008
Posts: 16,676

Rep: Reputation: 2454Reputation: 2454Reputation: 2454Reputation: 2454Reputation: 2454Reputation: 2454Reputation: 2454Reputation: 2454Reputation: 2454Reputation: 2454Reputation: 2454
"My understanding was swap wil be used only when there is RAM crunch issue"

I would have thought that too but seems there are some other factors going on. I researched this a bit a while ago. Seems that what you say can happen under some issues and to make things worse the swap doesn't flush parts.

The cure is not an exact cure. One part is to see if the app is locking up swap bit by bit or is it a one time shot that goes to swap.

I'd maybe start by changing the swappiness of your swap.

If this application just can't be fixed or figured out you might end up using a combined swap of multiple to act like a swap raid.

Might end up having to force swap to clear based on time or metric.
 
Old 08-09-2012, 05:57 PM   #9
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190
Quote:
Originally Posted by vicky007aggrwal View Post
swap memory is getting used fully even when the Free space is available in RAM
...
My application setting
RAM- 10 G
SWAP 3 G
Use of some swap despite free ram is common. Use of 3GB of swap despite free ram is unusual, but still might be normal behavior. You haven't provided enough info.

Linux does not pull pages back from swap until they are accessed again. So if memory was used and then freed, you might leave a lot of swap space in use.

If you do have a problem, it is likely a memory leak in some process. To further investigate that, you would need to look into those processes with high virtual memory use and then look into whether that use is "anonymous" (possible memory leak) vs. file mappings (which don't contribute to swap usage).

Quote:
Originally Posted by jefro View Post
I'd maybe start by changing the swappiness of your swap.
...
Might end up having to force swap to clear based on time or metric.
Both very bad ideas. You are attacking the symptom rather than the problem and doing it in a way that does more harm than just ignoring the problem would do.

If there is a memory leak or other problem, you need to start by identifying the problem processes, then deal with it or ignore it based on understanding what those processes are doing. But "deal with it" will not involve either of those methods of attacking the symptom.

Last edited by johnsfine; 08-09-2012 at 06:02 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Why size of swap space is 2x of RAM??? Why not 1.5x of RAM or 2.5x of RAM??? Saurav Ghosh Linux - Newbie 7 11-01-2011 03:49 AM
[SOLVED] Existeth a way to 'clear out' all the old/cached crap from RAM/SWAP to free up space? GrapefruiTgirl Linux - General 37 07-29-2010 12:46 PM
Need for SWAP with 1 GB RAM? Aleksandersen Linux - Newbie 36 02-26-2007 07:54 PM
Odd swap usage even though there is free RAM Artanicus Linux - Hardware 5 09-28-2005 02:25 AM
RAM and Swap shiny_spoon Linux - General 5 01-13-2004 02:27 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:58 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration