LinuxQuestions.org
Review your favorite Linux distribution.
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 10-11-2012, 05:29 AM   #1
subankar
LQ Newbie
 
Registered: Oct 2012
Posts: 2

Rep: Reputation: Disabled
Why swap space did not function when physical memory ( RAM ) is full ?


Hi,

Please give me some idea regarding subjected question. please have a look on the info below of our running system.

Real Memory: 3.95G
current used: 3.80G

Swap space: 4G
current used: 108.00k
 
Old 10-11-2012, 06:18 AM   #2
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,261

Rep: Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028
It is working; if it wasn't, used swap would be 0 (zero).
Try the top cmd
Code:
>top

top - 21:13:38 up  4:15,  2 users,  load average: 0.06, 0.07, 0.06
Tasks: 179 total,   2 running, 177 sleeping,   0 stopped,   0 zombie
Cpu(s):  1.3%us,  0.7%sy,  0.0%ni, 98.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   7801480k total,  2402840k used,  5398640k free,   114032k buffers
Swap:  3897336k total,        0k used,  3897336k free,   737952k cached


>free
              total       used       free     shared    buffers     cached
Mem:       7801480    2378792    5422688          0     114324     739324
-/+ buffers/cache:    1525144    6276336
Swap:      3897336          0    3897336
Also, read http://www.linuxatemyram.com/

PS: my used swap is zero because the system is under utilised
 
Old 10-11-2012, 06:30 AM   #3
subankar
LQ Newbie
 
Registered: Oct 2012
Posts: 2

Original Poster
Rep: Reputation: Disabled
swap memory is not using so far i understood because,
current swap used: 108.00k is remain unchanged from the very beginning. Can i use both memory in parallel.

Thanks
 
Old 10-11-2012, 06:39 AM   #4
pan64
Senior Member
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 4,606

Rep: Reputation: 1242Reputation: 1242Reputation: 1242Reputation: 1242Reputation: 1242Reputation: 1242Reputation: 1242Reputation: 1242Reputation: 1242
Just read the link http://www.linuxatemyram.com/. You can use swap of course, but you cannot force your os to use swap if it does not need it.
 
Old 10-11-2012, 06:39 AM   #5
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,522
Blog Entries: 2

Rep: Reputation: 4020Reputation: 4020Reputation: 4020Reputation: 4020Reputation: 4020Reputation: 4020Reputation: 4020Reputation: 4020Reputation: 4020Reputation: 4020Reputation: 4020
Please post the output of
Code:
free -m
between code-tags.
 
Old 10-11-2012, 09:15 AM   #6
johnsfine
Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,068

Rep: Reputation: 1106Reputation: 1106Reputation: 1106Reputation: 1106Reputation: 1106Reputation: 1106Reputation: 1106Reputation: 1106Reputation: 1106
Quote:
Originally Posted by subankar View Post
swap memory is not using so far i understood because,
current swap used: 108.00k is remain unchanged from the very beginning.
That doesn't mean it isn't being used or isn't functioning. It just means the amount that has been used was used before you noticed.

Quote:
Can i use both memory in parallel.
You should understand that swap space is so much slower than ram that you want to use ram as much as possible and only use swap space when that use makes room in ram for something more important. That is exactly what is already happening on your system.

You should also understand that only certain kinds of memory contents require the use of swap space to remove them from ram. Quite a lot of ram is occupied by executable code and other contents that are still associated with the files they were loaded from. If any of that content must be removed from ram to make room for other things, Linux does not need to write that to swap. Instead it simply discards the copy in ram, knowing that it can reload from the original file later.

Because that discard/reload sequence typically costs only half the disk access time of write/read-back to swap, Linux is biased in favor of dropping contents that don't need swap, rather than contents that do need swap. So in a system with a light memory load (which yours is, despite ram being "full") swap is typically used only for data that is created as a side effect of service processes starting (and isn't really needed for continuing operation of those processes). Once the cache fills up the ram, that stale data from service processes gets swapped out, then never comes back in (except maybe for a moment during shutdown of those services).

But typically, everything else you do with the kind of content that could be swapped is short lived or recent enough compared to cache that it is not productive to swap it out. So as you saw, the amount of used swap space isn't changing.

Quote:
Originally Posted by TobiSGD View Post
Please post the output of
Code:
free -m
between code-tags.
That info would tend to confirm what we already know about the situation in the OP's memory use. I'm sure there would be no surprise there.

Quote:
Originally Posted by pan64 View Post
You can use swap of course, but you cannot force your os to use swap if it does not need it.
Sure you can. First you adjust the swappiness parameter so Linux is no longer biased in favor of dropping cache and against using swap space. Next you run some activity that reads a lot of files, making the file cache content in ram newer than the anonymous data of all your other processes. Result: the anonymous data of all your other processes will be pushed out to swap, even though the os doesn't "need" to keep so much in cache and likely wouldn't keep so much in cache if swappiness were tuned correctly. Of course that would be a stupid thing to do.

Last edited by johnsfine; 10-11-2012 at 09:26 AM.
 
Old 10-11-2012, 10:39 AM   #7
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,522
Blog Entries: 2

Rep: Reputation: 4020Reputation: 4020Reputation: 4020Reputation: 4020Reputation: 4020Reputation: 4020Reputation: 4020Reputation: 4020Reputation: 4020Reputation: 4020Reputation: 4020
Quote:
Originally Posted by johnsfine View Post
That info would tend to confirm what we already know about the situation in the OP's memory use. I'm sure there would be no surprise there.
The point is that we know nothing about the memory use besides what the OP states he thinks is the memory use. So the output of free will show us what really is happening.
 
Old 10-11-2012, 12:02 PM   #8
johnsfine
Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,068

Rep: Reputation: 1106Reputation: 1106Reputation: 1106Reputation: 1106Reputation: 1106Reputation: 1106Reputation: 1106Reputation: 1106Reputation: 1106
Quote:
Originally Posted by TobiSGD View Post
The point is that we know nothing about the memory use besides what the OP states he thinks is the memory use. So the output of free will show us what really is happening.
I didn't want to make a fight out of that. I just didn't want the OP to think that the answer will change after we see output from free.

We know there is plenty of ram and it is almost all "used". We know there is plenty of swap space and a very small unchanging amount of that is used.

From those we can infer quite a lot. We can infer that free would tell us that a lot of ram is used by buffers and cache. The LinuxAteMyRam link has already explained that the large amount of ram "used" by buffers and cache is effectively free.

If there were not a large amount of ram effectively free, then the swap usage would be larger and varying.
 
  


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
Physical RAM and SWAP Memory devUnix Linux - Server 5 12-18-2010 08:51 AM
Swap space did not function when physical memory ( RAM ) is full rabbit00 Linux - Newbie 19 07-06-2009 09:18 PM
my physical memory just get full hua Slackware 15 06-28-2007 03:50 PM
how to use swap more than the physical memory Santosh_d Linux - General 9 03-24-2004 02:51 PM


All times are GMT -5. The time now is 11:09 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration