![]() ![]() Since we're talking about memory here, it's worth mentioning that when memory is critically low or threatening the stability of the system, Linux can trigger the Out of Memory (OOM) Killer functionality. If memory continued to be a problem, Linux could opt to use its swap address and as memory is swapped in/out of disk, we should see the values of si/ so increasing. They immediately start building up again and 6 seconds later, values are much higher: In this particular case, the fact that buff/cache is reducing significantly in size, indicates that Linux no longer has the luxury of using buff/cache for other purposes that much and is now prioritising our. This is also the reason why top command shows both of them together:įor Linux, idle RAM is a waste when it can be used for faster access to read frequently used data or to buffer data for faster retrieval.įor this reason, Linux uses a lot of buff/cache so in reality, the total amount of free memory on Linux is the sum of free + buff/cache. Since 2.4.10, both page and buffer cache are unified so we look at them together here. Notice that it starts out with about 2.7G (2759796 KB) and sharply decreases to just 107 MB (107876 KB) in 8 seconds:Īs soon as memory is freed, it sharply rises back to 3 GB (3039684 KB): buff/cacheīuff/cache are kept high in a healthy Linux system with plenty of memory available to make the most of available RAM.Ĭache is the size of memory page cache and buffers is the size of in-memory block I/O buffers. freeįree shows the amount of memory that is 100% physically free/idle. Once observing free and a 2nd time observing buff/cache. I encourage you to go through the above animation 2 times. after we free up memory so we can see how free counters recover from memory pressure. I recorded a couple of seconds after program finished running, i.e. On the left terminal, I'm executing watch -n 1 vmstat command and on the right terminal I'm running my C script. I then compiled the code using gcc command: It then waits 5 seconds before freeing up memory to give us some time to look at memory usage before program frees up memory. To quickly increase memory usage, I wrote a simple C program that allocates 3 GB of RAM to an array of integers. I'll use vmstat to watch free, buffers and cached counters to watch how they react to a sharp memory increase. This article is just a quick hands-on practical example to show how a typical Linux system usually reacts when memory pressure builds up quickly.
0 Comments
Leave a Reply. |