LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 01-15-2010, 02:25 AM   #1
thomas2004ch
Member
 
Registered: Aug 2009
Posts: 539

Rep: Reputation: 33
How to understand the result from 'free'?


I list the memory with 'free' and got followings:
Code:
             total       used       free     shared    buffers     cached
Mem:       3864624    2886828     977796          0     247564     730480
-/+ buffers/cache:    1908784    1955840
Swap:      1044184          0    1044184
One can see the total and free of Swap are the same. What does this mean?
 
Old 01-15-2010, 03:06 AM   #2
kilgoretrout
Senior Member
 
Registered: Oct 2003
Posts: 2,987

Rep: Reputation: 388Reputation: 388Reputation: 388Reputation: 388
It means no swap is being used which is not surprising since you seem to have 4GB of ram.
 
Old 01-15-2010, 03:38 AM   #3
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
Quote:
Originally Posted by kilgoretrout
It means no swap is being used which is not surprising since you seem to have 4GB of ram.
Does it mean no swap partition has been created ???
 
Old 01-15-2010, 04:02 AM   #4
thomas2004ch
Member
 
Registered: Aug 2009
Posts: 539

Original Poster
Rep: Reputation: 33
Quote:
Originally Posted by kilgoretrout View Post
It means no swap is being used which is not surprising since you seem to have 4GB of ram.
Here is another one:
Code:
             total       used       free     shared    buffers     cached
Mem:       3088968    2718840     370128          0     116228     172136
-/+ buffers/cache:    2430476     658492
Swap:      1044184      43812    1000372
The ram is 3 GB but it takes some swap. Why?
 
Old 01-15-2010, 07:29 AM   #5
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,803
Blog Entries: 1

Rep: Reputation: 422Reputation: 422Reputation: 422Reputation: 422Reputation: 422
Quote:
Originally Posted by thomas2004ch
The ram is 3 GB but it takes some swap. Why?
Apparently at some point over 3GB of RAM was being used and the system needed to put something in swap. To be honest, I'm not seeing anything unusual there.


Quote:
Originally Posted by anishakaul
Does it mean no swap partition has been created ???
The fact that there is an entry for Swap in the total column means that yes, a swap partition was created. It just wasn't being used.
 
1 members found this post helpful.
Old 01-15-2010, 07:36 AM   #6
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
Quote:
Originally Posted by Hangdog42
The fact that there is an entry for Swap in the total column means that yes, a swap partition was created. It just wasn't being used.
Isn't it surprising that no swap is being used at all ?
In which case does this happen ?
In my computer whenever I do "free" swap column is never shown 0 !
 
Old 01-15-2010, 07:50 AM   #7
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,803
Blog Entries: 1

Rep: Reputation: 422Reputation: 422Reputation: 422Reputation: 422Reputation: 422
Quote:
Isn't it surprising that no swap is being used at all ? In which case does this happen ?
Actually, no it isn't surprising, particularly with 4GB of RAM. I've got 4GB on my main laptop and I've never seen swap used. Heck, on my netbook I've got 2GB of RAM and never created a swap partition and it runs without a problem. Linux is actually pretty intelligent about how it uses RAM and since swap is glacially slow compared to RAM it doesn't use it unless it has to.

Quote:
In my computer whenever I do "free" swap column is never shown 0 !
Well, swap usage is a function of how much RAM is available and what services are running. The fact that I don't even have swap on my netbook reflects that it has a decent amount of RAM relative to the work I do with it. It runs things like a browser and word processor. If I were trying to serve tons of web pages or run databases on it, the lack of swap would likely be a problem. I've got a similar amount of RAM on my server and that is almost always using some swap, but that is running Apache, MySQL, SAMBA and a few other things.
 
1 members found this post helpful.
Old 01-15-2010, 11:30 AM   #8
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Most of the above discussion ignores the important interaction between swap and cache.

Linux keeps recently read pages in cache. That includes pages of data files your applications may have read as well as pages of read only file mappings (such as .so file and the main executable) that have been faulted out of a process's working set but not all the way out of physical ram.

If something needs memory and swap space is not available, then Linux must take that memory by reducing the cache. Sometimes that results in worse performance than if the swap space had been available.

If something needs memory and swap space is available, Linux will still usually take from the cache rather than swap pages out to swap space. But most systems have some processes that are either idle or have stale anonymous data, so there are anonymous data pages whose most recent access is significantly older than the most recent access of any read only mappings in the cache. Then it makes sense to swap those idle pages out to swap space in order to keep the cache large.

So, with plenty of ram and little enough file I/O and read only mapping that the cache never grows big enough to take most of the free memory, obviously the swap will never be used.

However with plenty of ram so the system never "needs" to use swap, but with enough recent file I/O or read only mapping that the cache is "full" (free memory outside the cache minimal) and also everything in the cache is newer than some stale anonymous pages, then Linux will correctly use some swap space even though it doesn't "need" to.
 
Old 01-22-2010, 02:23 AM   #9
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
@Hangdog42

Many thanks for the info

I was not aware of the fact that swap partition is not always necessary. Today I did a free on my computer and saw 0 swap used.

Can we create a swap partition later on if we realize, that now system gets loaded too much and swap is necessary ??
 
Old 01-22-2010, 02:35 AM   #10
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Yes you could. If you have 4 GB of ram and are using a 32bit distro, you have as much real ram as address space unless you use a PAE kernel. Many programs and services will use some memory when they are starting up but the memory may not be used again. Memory like that that doesn't used for a long time may get swapped out freeing more real memory for your applications. Also the swap partition is used if you suspend your computer. The rule of thumb I use for over 2 GB of ram is to make the swap partition a bit larger then the amount of ram. Drives are very large now so it shouldn't be missed.
 
Old 01-22-2010, 07:11 AM   #11
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,803
Blog Entries: 1

Rep: Reputation: 422Reputation: 422Reputation: 422Reputation: 422Reputation: 422
I guess my rule of thumb is that if you have decent disk space, you should probably have some swap from the get-go. Yes, you can add a swap partition after install (provided you can re-partition your drive), but it is usually easier to do that at install time. There are a couple of reasons why I didn't put a swap partition on my netbook. First, it has a 16GB drive and I need every last GB of that for software. Second, the 16GB drive is an SSD and I wanted to eliminate as many read/write cycles as possible to preserve the drive life.


Quote:
Originally Posted by jschiwal
Also the swap partition is used if you suspend your computer
You're right you do need swap to hibernate your computer (suspend to disk), but I don't think you need it to suspend to RAM.
 
Old 01-24-2010, 06:54 PM   #12
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Here is RH's take on swap allocation: http://kbase.redhat.com/faq/docs/DOC-15252
 
1 members found this post helpful.
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Question regarding this line "Free taken as in free speech, not free beer" SHENGTON Linux - Newbie 11 01-12-2009 07:40 AM
Disk free space issues as result of (suspected) silly installation Bethmo Mandriva 10 07-13-2008 08:28 PM
Disk free result "df" differs from "du" ongi Linux - Server 4 04-01-2008 07:10 AM
LXer: Free Me: a DVD about free culture and free software LXer Syndicated Linux News 0 03-12-2007 12:01 PM
Who know about the lmbench? I can not understand the test result. Linfish Linux - Software 0 07-13-2004 04:17 AM

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

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