LinuxQuestions.org
Visit Jeremy's Blog.
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 02-01-2012, 03:38 PM   #1
pwnage101
LQ Newbie
 
Registered: Dec 2011
Distribution: openSUSE
Posts: 9

Rep: Reputation: Disabled
swap vs cache


My computer has 6gb physical RAM, and a 6gb swap partition. After a 1-2 weeks of uptime of using chromium, skype, clementine, and dropbox, my memory statistics is as follows:

active: 3123
cache: 2242
free: 418
swap: 1612

I'm not so concerned about high memory usage, but rather concerned about cached memory that could be freed to make room for whatever is in the swap. Is that a not-so-good idea? Should I be doing something different to prevent the constant swap usage?

Thanks!
 
Old 02-01-2012, 03:45 PM   #2
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,134
Blog Entries: 2

Rep: Reputation: 4839Reputation: 4839Reputation: 4839Reputation: 4839Reputation: 4839Reputation: 4839Reputation: 4839Reputation: 4839Reputation: 4839Reputation: 4839Reputation: 4839
This is nothing to be concerned about. The system swapped out seldom used memory pages to have more space used as cache. This will actually increase the speed of your system, only when you use the application that is swapped out you will see a delay when the pages are loaded back into RAM.
 
1 members found this post helpful.
Old 02-01-2012, 05:42 PM   #3
jefro
Moderator
 
Registered: Mar 2008
Posts: 16,878

Rep: Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489
Before I ask a dumb question could you please post two things?

/proc/meminfo

and

output of vmstat -a or at least vmstat if you have it.
 
1 members found this post helpful.
Old 02-01-2012, 06:03 PM   #4
pwnage101
LQ Newbie
 
Registered: Dec 2011
Distribution: openSUSE
Posts: 9

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by jefro View Post
Before I ask a dumb question could you please post two things?

/proc/meminfo

and

output of vmstat -a or at least vmstat if you have it.
About once every other week my computer fails to wake from sleep, and it happened just right now. Now my computer has only minutes of uptime, and has 3393 MB free memory. I don't start hitting swap until at least a couple of days so I can't imagine that info being of any use right now (right?).
 
Old 02-02-2012, 06:35 AM   #5
salasi
Senior Member
 
Registered: Jul 2007
Location: Directly above centre of the earth, UK
Distribution: SuSE, plus some hopping
Posts: 4,062

Rep: Reputation: 893Reputation: 893Reputation: 893Reputation: 893Reputation: 893Reputation: 893Reputation: 893
Quote:
Originally Posted by pwnage101 View Post
Should I be doing something different to prevent the constant swap usage?
Having some swap pages in use is not, per se, a problem for normal operation. Having traffic to and from the swap volume is a problem...well, at least, a problem if the result is enough slowness to be a problem.

Quote:
About once every other week my computer fails to wake from sleep, and it happened just right now. Now my computer has only minutes of uptime, and has 3393 MB free memory. I don't start hitting swap until at least a couple of days so I can't imagine that info being of any use right now (right?).
This may or may not be a concern to you, but there may be a connection. That is, if you suspend to disk, you need enough swap space defined in order to swap to. If you are filling up your ram and you are using some swap space as well, there may well not be enough space to swap to. This will cause the symptom that you are having - as I say, it is not clear whether this is a problem to you, but, if it is, you could define another swap space (either make a partition available for that, by a bit of partition shuffling, or a swap file).

If it was me, I'd want to run vmstat now - now is when the system is running well, and a vmstat run now will give you the 'before' reference. If you run something like 'vmstat 2 10' now, and run it again, once your memory usage has gone up, you should be able to see the difference. (Also, have a look at the man page for vmstat; there is an important note about the first response.)
 
1 members found this post helpful.
Old 02-02-2012, 12:45 PM   #6
pwnage101
LQ Newbie
 
Registered: Dec 2011
Distribution: openSUSE
Posts: 9

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by salasi View Post
This may or may not be a concern to you, but there may be a connection. That is, if you suspend to disk, you need enough swap space defined in order to swap to. If you are filling up your ram and you are using some swap space as well, there may well not be enough space to swap to. This will cause the symptom that you are having - as I say, it is not clear whether this is a problem to you, but, if it is, you could define another swap space (either make a partition available for that, by a bit of partition shuffling, or a swap file).

If it was me, I'd want to run vmstat now - now is when the system is running well, and a vmstat run now will give you the 'before' reference. If you run something like 'vmstat 2 10' now, and run it again, once your memory usage has gone up, you should be able to see the difference. (Also, have a look at the man page for vmstat; there is an important note about the first response.)
Actually I already determined the sleep problem: buggy proprietary fglrx ATI drivers. Perhaps the drivers are related to swap, I don't know. There are several different workarounds for different thinkpad models but I have an ASUS with a different video card than those other laptops. I have not gotten around to attempting each fix, one at a time, partly because some workarounds warn that corruption is possible. I can switch to the open source drivers, which I have done in the past, and that does fix the problem but idles my video card at 75C rather than 66C (as with fglrx). High temperatures wouldn't normally bother me, but I do hate the sound of fans at high RPMs especially when I have sleeping roommates.

Furthermore I suspend to RAM, not disk. I'll note the vmstat anyway, thanks for your insight

Last edited by pwnage101; 02-02-2012 at 03:09 PM.
 
Old 02-02-2012, 01:24 PM   #7
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 pwnage101 View Post
About once every other week my computer fails to wake from sleep, and it happened just right now. ... I can't imagine that info being of any use right now (right?).
I don't have any guesses about the sleep issue. You don't seem to be saying you think it is related to the swap usage.

But anyway, you are correct that detailed memory stats would not be helpful if captured when the condition being investigated isn't happening.

Quote:
Originally Posted by TobiSGD View Post
This is nothing to be concerned about.
Generally true. But I wouldn't rule out a memory leak based on the numbers posted, without more detailed info.

Quote:
when you use the application that is swapped out you will see a delay when the pages are loaded back into RAM.
Sometimes that is true, in which case the use of swap to increase caching has gained throughput (overall system speed) at the expense of responsiveness (perceived system speed) and most people would prefer responsiveness. But that "sometimes" seems less likely in this case and the controls are crude, so I suspect no responsiveness can be gained by reducing swap usage.

Many service processes use a lot of anonymous memory on startup that is then untouched until the service is shut down. With a light memory load, it may take days for the kernel to figure out those pages are stale, then it correctly swaps out the stale pages and leaves them out, which does no harm to the subsequent performance of those services. The amount of swap use here seems a bit high for that, but I don't know much about the specific service processes that are running. If this is the correct diagnosis than nothing is wrong and that use of swap space is optimal for both throughput and responsiveness.

Some process(es) might have memory leaks. That typically means the process gradually accumulates more stale pages that it owns but doesn't touch. The kernel gradually swaps those pages out and leaves them swapped out, which eliminates the major short term consequences of the memory leak. But eventually a memory leaking process will need to be shut down and restarted. Often the memory leaking process is the main GUI system, so shutting it down an restarting forces shutting down and restarting all GUI programs, which for most people is more hassle than completely rebooting.

Last edited by johnsfine; 02-02-2012 at 01:40 PM.
 
1 members found this post helpful.
  


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
Manipulating Swap vs Disk Cache MikeyCarter Linux - Software 1 02-22-2008 09:06 PM
Swap vs Disk Cache MikeyCarter Fedora 2 12-23-2007 07:00 PM
Cache Swap Directory Creation Problem arun_ain Linux - Software 4 06-14-2005 04:45 AM
Writing swap cache to HD on demand MasterC Linux - General 2 02-27-2004 02:19 PM
squid cache server- error creating swap directory debloxie Linux - Networking 4 01-19-2004 12:49 AM

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

All times are GMT -5. The time now is 02:18 AM.

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