LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-19-2009, 03:21 AM   #1
Manjunath1847
Member
 
Registered: Mar 2007
Posts: 44

Rep: Reputation: 16
Finding Buffer cache size


Hi,

is there any way to know the amount of actuall amount free memory available at runtime. I mean how to find the amount of available free memory + current buffer cache size.
Amount of available free memory can be found using - linux API sysconf(_SC_AVPHYS_PAGES). Similarly is there any way to find the current buffer cache size
 
Old 03-20-2009, 06:22 AM   #2
alan_ri
Senior Member
 
Registered: Dec 2007
Location: Croatia
Distribution: Debian GNU/Linux
Posts: 1,733
Blog Entries: 5

Rep: Reputation: 127Reputation: 127
free command

man free for help
 
Old 03-20-2009, 06:43 AM   #3
Manjunath1847
Member
 
Registered: Mar 2007
Posts: 44

Original Poster
Rep: Reputation: 16
"free" is a command, to find the free memory and buffer cache. But I need to find these values from the program i.e at runtime. Is there any API to get the currect buffer cache size.

Thanks in advance

Quote:
Originally Posted by alan_ri View Post
free command

man free for help
 
Old 03-20-2009, 11:30 PM   #4
alan_ri
Senior Member
 
Registered: Dec 2007
Location: Croatia
Distribution: Debian GNU/Linux
Posts: 1,733
Blog Entries: 5

Rep: Reputation: 127Reputation: 127
Well,you can have a look here: http://www.codase.com/linux.html to see what might be of any interest to you.
 
Old 03-20-2009, 11:58 PM   #5
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,314

Rep: Reputation: 4172Reputation: 4172Reputation: 4172Reputation: 4172Reputation: 4172Reputation: 4172Reputation: 4172Reputation: 4172Reputation: 4172Reputation: 4172Reputation: 4172
Get it from the same place free does - /proc/meminfo
 
Old 03-21-2009, 04:14 AM   #6
Manjunath1847
Member
 
Registered: Mar 2007
Posts: 44

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by alan_ri View Post
Well,you can have a look here: http://www.codase.com/linux.html to see what might be of any interest to you.
Thanks, will check
 
Old 03-21-2009, 04:18 AM   #7
Manjunath1847
Member
 
Registered: Mar 2007
Posts: 44

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by syg00 View Post
Get it from the same place free does - /proc/meminfo

Yes thats right. But in my case, I need to check actual amount of free memory each time before I start the operation. This operation is started from the user, which we dont have control. So reading and parsing for free memory from file (i.e /etc/meminfo) each time before starting operation would be time consuming.
 
Old 03-21-2009, 08:16 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 Manjunath1847 View Post
I need to check actual amount of free memory each time before I start the operation. This operation is started from the user, which we dont have control. So reading and parsing for free memory from file (i.e /etc/meminfo) each time before starting operation would be time consuming.
Maybe reading and parsing /proc/meminfo will be much faster than you expect.

If you are starting an operation so memory intensive that you need to check the system wide memory resources, the cost of that check will be relatively tiny.

Notice also, syg00 to did not say "file (i.e /etc/meminfo)". He said "/proc/meminfo". That is not an ordinary file. You read it like a file, but the kernel code servicing it is doing something very different from code reading an actual file.
 
Old 03-21-2009, 10:15 AM   #9
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 11,056
Blog Entries: 4

Rep: Reputation: 4068Reputation: 4068Reputation: 4068Reputation: 4068Reputation: 4068Reputation: 4068Reputation: 4068Reputation: 4068Reputation: 4068Reputation: 4068Reputation: 4068
Parsing of the file is, indeed, the way to find this info... but you may be barking up the wrong tree.

The file-buffer space is a variable-sized, low-priority memory pool. Basically, the kernel always wants 100% of memory to be in-use doing "something," and file-buffering is a low-priority use for it. If other forms of memory-pressure arise, the file-buffer pool shrinks.
 
  


Reply

Tags
buffer, cache


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
Difference between page cache and buffer cache Nayaka Linux - Kernel 5 09-28-2011 09:23 AM
Buffer cache jeesun Linux - Enterprise 1 10-07-2007 08:29 AM
buffer cache size gsr_kashyap Red Hat 6 09-18-2006 02:15 AM
buffer cache in minix computer Linux - Newbie 1 02-09-2006 11:53 AM
file buffer cache jwstric2 Linux - General 2 06-30-2004 05:25 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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