Open koshell opened 1 year ago
Seems like the sysinfo
system call doesn't provide info on cache memory unfortunately... so some direct parsing of /proc/meminfo
would have to be done.
https://stackoverflow.com/questions/349889/how-do-you-determine-the-amount-of-linux-system-ram-in-c
Being brief, the memory and memory2 blocks give hilariously different results.
Best I can tell the math used by the memory2 block to calculate free ram is wrong. The block uses an assumption like 'Used Memory = Total Memory - Free Memory' however Linux tries very hard to not actually leave any wasted 'free' memory floating around. Instead the correct way to calculate it would be something like: 'Actual Memory Usage = Total - (Free + Buffers + Cached)' (I got the math from https://scoutapm.com/blog/determining-free-memory-on-linux )
This is why the script (memory) says for example I am only using 30% of my ram but the C program (memory2) says I am using 99%.