sorry, somehow your question has slipped by - usually I jump at this type of posts
how to calculate the amount of memory free in SUSE
Please define “memory free”
Because of the memory model, especially the impact of virtual memory, there are more than one definition, and each answer would actually serve a purpose (and not be purely academical):
free physical memory (“MemFree: 703472 kB”)
This value is optimized to “almost zero” on Linux systems, as “free physical memory” can serve a better purpose than to idle away… most easily it can be used as buffer/cache space for physical (disk) I/O… if you have a lot of free physical memory, either something is wrong or you have (had) less disk i/o than available free physical memory, IOW a system that is pretty much idle
physical memory available to applications (MemFree+Buffers+Cached, minus x%)
Linux will automatically shrink the I/O buffer (but not to zero) rather than using virtual memory. So the memory your applications can use up, without causing swapping, is the sum of already free physical memory plus the memory that can be freed from buffers and cache.
Please note that this may still have some impact on performance: As less space is available for I/O buffers, I/O-intensive tasks will notice waiting time when accessing disks.
memory available to applications ( SwapFree + (MemFree+Buffers+Cached) * 0,x )
Once the physical memory is used up, the memory manager will try to page out memory to (slower) storage. Commonly called “swapping”, but actually it is “paging”… just to have it mentioned.
When your system starts paging, things usually get slow. And if you have much paging, things may slow down almost to a halt. It’s something to avoid
“active” and “inactive” refers to the state of swapped/cached memory: If that memory has not been modified since reading from disk, it can be freed if memory is tight, and is called “inactive”. Once the content is changed, it needs to be written to disk before freeing that piece of memory, and called “active”.
I’m sure you’re after some specific answer and probably not just trying to understand the mechanics of Linux memory management. As there are many tunables in this area, it would be better to know some background, in order to give you properly matching answers.
Thanks a lot for your clarification. My question is about free memory from application point of view. That’s your #3 item.
The fact is that I want to remove tmpfs file out of my calculation. For example: if I create a 100MB tmpfs file i.e in my case it is under /dev/shm, this file will either be stored in cached or swap-used and cached or swap-used will increase 100MB. These files under /dev/shm can not be moved to anywhere else if we are running out of physical mem and swap, thus I want to exclude tmpfs out of my formula. In other words, my formula would be:
total free memory = mem_free + swap_free + active_file + inactive_file
A hint from http://blog.thewebsitepeople.org/2011/03/linux-memory-leak-detection/ is all I have. I’m not sure if my formula is usable.