I’m a new comer. I’m not sure if I post my question in the right place but if it is please help me to change to the right box.
I have a question about how to calculate the amount of memory free in SUSE. With my understanding:
Total mem free = Memory free + Swap free + Buffer + Cached (I assume Swap is free memory as well in my calculation).
I also found this link in the internet http://blog.thewebsitepeople.org/2011/03/linux-memory-leak-detection/ which state that:
Buffers + Cached = Active(file) + Inactive(file) + ?X?.
Thus, my formula would become:
Total mem free = Memory free + Swap free + Active(file) + Inactive(file) + ?X?.
1/ As the above link is not an official link from SUSE, I can not prove if the formula is correct. Do any one have any idea about my calculation?
2/ What does ?X? in the above formula stand for?
3/ I also noticed that tmpfs is used in my system, about 101MB, please see example below. So the total of memory free must exclude tmpfs. Is my calculation correct for this case as well? If not, any suggestion?
I would be very appreciated if someone could clarify my confuse as I hardly find these kind of information in the internet.
I’m a new comer. I’m not sure if I post my question in the right place but if it is please help me to change to the right box.
I have a question about how to calculate the amount of memory free in SUSE. With my understanding:
Total mem free = Memory free + Swap free + Buffer + Cached (I assume Swap is free memory as well in my calculation).
I also found this link in the internet http://blog.thewebsitepeople.org/2011/03/linux-memory-leak-detection/ which state that:
Buffers + Cached = Active(file) + Inactive(file) + ?X?.
Thus, my formula would become:
Total mem free = Memory free + Swap free + Active(file) + Inactive(file) + ?X?.
1/ As the above link is not an official link from SUSE, I can not prove if the formula is correct. Do any one have any idea about my calculation?
2/ What does ?X? in the above formula stand for?
3/ I also noticed that tmpfs is used in my system, about 101MB, please see example below. So the total of memory free must exclude tmpfs. Is my calculation correct for this case as well? If not, any suggestion?
I would be very appreciated if someone could clarify my confuse as I hardly find these kind of information in the internet.
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.
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.
Regards,
Jens[/QUOTE]
Hi Jens,
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
for your purpose, I’d say use the “free” command and add up the values from the “free” column, row 2 and 3 (free physical memory after considering buffers and caches in line 2, free swap space on line 3).
Regards,
Jens
PS: A very short, end-user oriented description can be seen on http://www.linuxatemyram.com/ - I like that table comparing users’ to system view of the term “free”