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 |
free command
man free for help |
"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:
|
Well,you can have a look here: http://www.codase.com/linux.html to see what might be of any interest to you.
|
Get it from the same place free does - /proc/meminfo
|
Quote:
|
Quote:
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. |
Quote:
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. |
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. |