LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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 03-03-2012, 01:46 PM   #1
circus78
Member
 
Registered: Dec 2011
Posts: 273

Rep: Reputation: Disabled
Question about "free" command


Hi,
I'm trying to determine how many memory I've in order to run Apache websites, so I'm using "free" command.
Should I consider the free one (first row) or the second (in the +/- buffer/cached row)?

Code:
# free
             total       used       free     shared    buffers     cached
Mem:       4063168    2679208    1383960          0      95140    1577976
-/+ buffers/cache:    1006092    3057076
Swap:      3906552     308760    3597792

Last edited by colucix; 03-03-2012 at 02:24 PM. Reason: Changed QUOTE with CODE tags to preserve spacing
 
Old 03-03-2012, 02:40 PM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
I'd say the second one. You have 3 Gb of memory readily made available to applications when requested. The free memory is somehow wasted, in the sense it would be better to use it, since reading data from disk is far slower than reading from memory. This is the reason why data are cached in memory: if they are used again, the cache will speed up the process.

Some useful information in the (unmaintained) Linux System Administrator's Guide and in this old (but still valid) article from Linux Journal.
 
Old 03-03-2012, 03:01 PM   #3
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
The second line is almost always the one the represents the true situation in the sense that you care about used vs. free memory.
In the case quoted by the first post, I would be extra confident that the second line is the meaningful line.
When a Linux system is under major memory pressure, it will soft fault a lot in addition to paging to/from disk. When there is a high rate of soft faults, the cache memory is effectively part of the resident memory of the active tasks, but not reported as such. Under that unusual case the second line of free output is misleading and the first line more informative. That does not imply I think any such thing is happening for the OP. It just means the claim that the second line is more meaningful than the first is not universally correct.
 
Old 03-04-2012, 04:26 AM   #4
circus78
Member
 
Registered: Dec 2011
Posts: 273

Original Poster
Rep: Reputation: Disabled
Hi,
thankyou for reply.

Perhaps I did not understand: the buffer/cache row is only speaking about "memory data" stored on hard disk?
So, If I've a lot of "%wa" (wait, in top command), should I think that things will runs very slow?
Thankyou again.
 
Old 03-04-2012, 07:22 AM   #5
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by circus78 View Post
Perhaps I did not understand: the buffer/cache row is only speaking about "memory data" stored on hard disk?
buffer/cache is ram used to store copies of data that is also on hard disk and that is not needed in ram at the moment.
If more ram is needed for some other purpose, it can be taken from buffer/cache. If instead, the data stored in buffer/cache happens to be needed it can be used immediately instead of reading it from disk.

Quote:
So, If I've a lot of "%wa" (wait, in top command), should I think that things will runs very slow?
Do you have a lot of "%wa" in top? I think that would mean the programs you are running are reading a lot of files from disk that have not been read before recently and thus are not in cache.

Last edited by johnsfine; 03-04-2012 at 07:25 AM.
 
Old 03-04-2012, 08:21 AM   #6
prowla
Member
 
Registered: Feb 2011
Location: UK
Distribution: RHEL 5 & 6, Ubuntu 10
Posts: 93

Rep: Reputation: 3
Alternatively, doing "top -n 1" will show memory used.
 
Old 03-04-2012, 10:00 AM   #7
circus78
Member
 
Registered: Dec 2011
Posts: 273

Original Poster
Rep: Reputation: Disabled
Hi,

so, memory listed in the buffer/cache relates to data that are currently in the physical ram (in my case: 4 GB) and can be quickly "replaced" according to application usage?
 
Old 03-04-2012, 10:12 AM   #8
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by circus78 View Post
memory listed in the buffer/cache relates to data that are currently in the physical ram (in my case: 4 GB) and can be quickly "replaced" according to application usage?
Yes, that is a reasonable way to describe it.
 
  


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
Output from "free" command: Difference between buffer and cache kenneho Linux - Kernel 2 09-05-2012 09:35 AM
Like to understand the linux "free" command with respect to cache and free memory bruzzese Linux - Server 2 03-28-2010 12:52 PM
How to decipher memory command "free" in terminal? linus72 Linux - General 4 07-22-2009 08:54 AM
Question regarding this line "Free taken as in free speech, not free beer" SHENGTON Linux - Newbie 11 01-12-2009 07:40 AM
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 10:18 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 09:41 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