Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is memory reclaim in linux

I am very new to Linux memory management concept while reading some memory management related document I had some basic doubt please clarify me.

considering below is my config

vm.swappiness=10
vm.vfs_cache_pressure=140
vm.min_free_kbytes=2013265 

My understanding if free memory is gone less than vm.min_free_kbytes OS will reclaim the memory.

1- Is Memory reclaim is a deletion of unwanted file or copying to Swap memory from RAM?

2- If it's copying to Swap memory from RAM, then if I am not using SWAP memory what will be happened?

3- Is swappiness is always greater than the vm.min_free_kbytes?

4-What the significants of vm.vfs_cache_pressure ?

Thank You..!!

like image 788
Mohamed Ashraf Avatar asked Feb 21 '17 04:02

Mohamed Ashraf


People also ask

What is process reclaim?

Land reclamation, usually known as reclamation, and also known as land fill (not to be confused with a waste landfill), is the process of creating new land from oceans, seas, riverbeds or lake beds. The land reclaimed is known as reclamation ground or land fill.

How do I free up memory on Linux?

The most common way you'll see on the web to check for free memory in Linux is by using the free command. Using the free -m command to check your Linux memory usage, displays the values as MB instead of KB. The free column beside -/+ buffers/cache with 823 MB is the actual free memory available to Linux.

What is cache memory in Linux?

Cache memory has an operating speed similar to the CPU itself so, when the CPU accesses data in cache, the CPU is not kept waiting for the data. Cache memory is configured such that, whenever data is to be read from RAM, the system hardware first checks to determine if the desired data is in cache.

What is page Reclaim?

The process whereby one member requests and is granted a page being used by another member is known as page reclaiming. If different members require access to the same page of data, the cluster caching facility manages which member accesses the page and when.


1 Answers

  1. Memory reclaim is the mechanism of creating more free RAM pages, by throwing somewhere else the data residing in them. It has nothing to do with files. When more RAM is needed, data is dropped from RAM (trashed away, if it can be refetched) or copied to the swap file (so the data will be refetchable).

  2. If there is not a swap file, but some data should be saved to the (non existent) swap area, then an out-of-memory error happens. Typically, this is notified to the process which is trying to get the memory (via alloc() and similar) - the alloc() fails and returns NULL. The process can choose what to do, or even crash. If the memory is needed by the kernel itself (normally quite rare), a PANIC happens and the system locks completely.

  3. swappiness is, in percentage, the tendency of the kernel to use the swap, even if not strictly needed, in order to have plenty of ram ready for memory requests. Simply put, a 100% swappiness means the kernel tries to always swap, a swappiness of 0 means the kernel tries to not do swap (there are some special values however). min_free_kbytes indicates real kilobytes, it is not a percentage, and it is the minimum amount that should always be free in order to let the kernel to work well. Even starting a memory reclaim could require some more ram to do the job: it would be catastrophic if, to get some memory, you need just a little memory but you don't have it! :-)

  4. vfs_cache_pressure is again a percentage. It indicates how much the kernel tries to get rid of (memory) cache used for the file system (vfs=virtual file system). The cache for the filesystem is quite a good candidate to throw away, because it keeps information easily readable from the disk. Unfortunately, if the computer needs frequently to use the file system, it has to read, and read again, and read again always the same data. Caching is a big performance boost. Of course, if a system does little disk I/O, then this cache is the best candidate to throw away when memory hungry.

All this things are succintly explained here: https://www.kernel.org/doc/Documentation/sysctl/vm.txt

like image 135
linuxfan says Reinstate Monica Avatar answered Oct 04 '22 16:10

linuxfan says Reinstate Monica