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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
03-19-2009, 03:21 AM
|
#1
|
Member
Registered: Mar 2007
Posts: 44
Rep:
|
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
|
|
|
03-20-2009, 06:22 AM
|
#2
|
Senior Member
Registered: Dec 2007
Location: Croatia
Distribution: Debian GNU/Linux
Posts: 1,733
Rep:
|
free command
man free for help
|
|
|
03-20-2009, 06:43 AM
|
#3
|
Member
Registered: Mar 2007
Posts: 44
Original Poster
Rep:
|
"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
free command
man free for help
|
|
|
|
03-20-2009, 11:30 PM
|
#4
|
Senior Member
Registered: Dec 2007
Location: Croatia
Distribution: Debian GNU/Linux
Posts: 1,733
Rep:
|
Well,you can have a look here: http://www.codase.com/linux.html to see what might be of any interest to you.
|
|
|
03-20-2009, 11:58 PM
|
#5
|
LQ Veteran
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,314
|
Get it from the same place free does - /proc/meminfo
|
|
|
03-21-2009, 04:14 AM
|
#6
|
Member
Registered: Mar 2007
Posts: 44
Original Poster
Rep:
|
Quote:
Originally Posted by alan_ri
|
Thanks, will check
|
|
|
03-21-2009, 04:18 AM
|
#7
|
Member
Registered: Mar 2007
Posts: 44
Original Poster
Rep:
|
Quote:
Originally Posted by syg00
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.
|
|
|
03-21-2009, 08:16 AM
|
#8
|
LQ Guru
Registered: Dec 2007
Distribution: Centos
Posts: 5,286
|
Quote:
Originally Posted by Manjunath1847
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.
|
|
|
03-21-2009, 10:15 AM
|
#9
|
LQ Guru
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 11,056
|
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.
|
|
|
All times are GMT -5. The time now is 11:55 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|