LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Finding Buffer cache size (https://www.linuxquestions.org/questions/linux-software-2/finding-buffer-cache-size-712730/)

Manjunath1847 03-19-2009 02:21 AM

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

alan_ri 03-20-2009 05:22 AM

free command

man free for help

Manjunath1847 03-20-2009 05:43 AM

"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 (Post 3481869)
free command

man free for help


alan_ri 03-20-2009 10:30 PM

Well,you can have a look here: http://www.codase.com/linux.html to see what might be of any interest to you.

syg00 03-20-2009 10:58 PM

Get it from the same place free does - /proc/meminfo

Manjunath1847 03-21-2009 03:14 AM

Quote:

Originally Posted by alan_ri (Post 3482730)
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

Manjunath1847 03-21-2009 03:18 AM

Quote:

Originally Posted by syg00 (Post 3482745)
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.

johnsfine 03-21-2009 07:16 AM

Quote:

Originally Posted by Manjunath1847 (Post 3482880)
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.

sundialsvcs 03-21-2009 09:15 AM

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 03:26 PM.