I've already searched for possible solutions, such as How to monitor the computer's cpu, memory, and disk usage in Java?. But memory spent in buffers and cache is not mentioned anywhere?
For example, on linux, output of free -m:
total used free shared buffers cached Mem: 2011 1835 175 0 309 847 -/+ buffers/cache: 678 1333 Swap: 1998 0 1998
I've already tested output of sigar, which reports free memory as 175 MB.
The cause of this question is how to detect when OS has little memory left? In the previous output of free -m
, 175 MB seems quite low; but by adding buffers and cache it is evident that free memory is actually 1333 MB out of 2 GB.
To summarise, using java, is it possible to get value 1333 MB as value of the free memory? As I've already mentioned, so far I know only how to get value of 175 MB.