LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-06-2006, 11:22 AM   #1
MasterOfTheWind
Member
 
Registered: Jul 2004
Distribution: Arch, Debian sid, Kubuntu, Slackware 11
Posts: 324

Rep: Reputation: 30
Why using swap when RAM is available?


Hi!

Have always wondered why kernel decides to use the swap space when RAM is not fully filled by application memory? Wouldn't it be better if some of the cached memory was removed and its place filled by the data stored on the swap partition?

In other words, isn't it better to have ALL memory on RAM (even if it means that there is no space left for caching) and nothing on the swap partition than a part of the app memory + cached memory on RAM and some app memory on the swap partition?

Thanks.
 
Old 10-06-2006, 11:34 AM   #2
pljvaldez
LQ Guru
 
Registered: Dec 2005
Location: Somewhere on the String
Distribution: Debian Wheezy (x86)
Posts: 6,094

Rep: Reputation: 281Reputation: 281Reputation: 281
I've never seen my swap used when RAM is enabled. Can you post the output of free -lm when this is happening?
 
Old 10-06-2006, 12:18 PM   #3
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Quote:
Originally Posted by MasterOfTheWind
Have always wondered why kernel decides to use the swap space when RAM is not fully filled by application memory?
The O/S try to always maintain as small amount or RAM free to ease future allocations.
When a process exits, all it's pages stored in RAM are freed, these free pages aren't filled by pages that are currently swapped out is there is no demand for them, so you can observe what you describes.
Quote:
Wouldn't it be better if some of the cached memory was removed and its place filled by the data stored on the swap partition?
No, why would you like unused pages to fill the precious RAM ?
 
Old 10-06-2006, 12:45 PM   #4
MasterOfTheWind
Member
 
Registered: Jul 2004
Distribution: Arch, Debian sid, Kubuntu, Slackware 11
Posts: 324

Original Poster
Rep: Reputation: 30
pljvaldez, here is the output (this is on my oldest laptop - haven't got the new one by my side, but it has the same behavior):

Code:
             total       used       free     shared    buffers     cached
Mem:            60         47         12          0          2         31
Low:            60         47         12
High:            0          0          0
-/+ buffers/cache:         12         47
Swap:          266          3        262
As you see, this is not a problem - only 3mb are located on the swap space.

And jlliagre has already answered why those are not copied back to RAM.

Thanks alot
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
When SWAP and RAM are out syberdave Linux - General 6 01-07-2006 12:13 AM
Use RAM as swap??? oneandoneis2 Linux - General 3 08-19-2004 04:48 AM
Not using RAM and Swap much ? ruwach Linux - Hardware 2 06-11-2004 07:26 AM
RAM and Swap shiny_spoon Linux - General 5 01-13-2004 02:27 PM
Swap and RAM ? mikeshn Linux - General 1 09-18-2002 09:33 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:08 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
Open Source Consulting | Domain Registration