LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   Why swap space did not function when physical memory ( RAM ) is full ? (http://www.linuxquestions.org/questions/linux-server-73/why-swap-space-did-not-function-when-physical-memory-ram-is-full-4175431643/)

subankar 10-11-2012 05:29 AM

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

chrism01 10-11-2012 06:18 AM

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

subankar 10-11-2012 06:30 AM

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

pan64 10-11-2012 06:39 AM

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.

TobiSGD 10-11-2012 06:39 AM

Please post the output of
Code:

free -m
between code-tags.

johnsfine 10-11-2012 09:15 AM

Quote:

Originally Posted by subankar (Post 4802887)
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 (Post 4802894)
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 (Post 4802893)
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.

TobiSGD 10-11-2012 10:39 AM

Quote:

Originally Posted by johnsfine (Post 4803021)
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.

johnsfine 10-11-2012 12:02 PM

Quote:

Originally Posted by TobiSGD (Post 4803104)
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.


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