Thursday 8 December 2016

Memory Management in Linux

Memory is very important in linux. We need to be very cautios while managing our memories. We need to figure out bottleneck and make sure we have enough memory so that application running in Linux runs smooth. Few are the parameters we need to keep in mind and tune memory.

vmstat - swap in and swap out should be less.
procps - rpm needed for vmstat
dstat --top-oom -- First process kernal is going to kill so that memory is freed
getconf PAGE_SIZE - To view page size(Memory)
Resident Memory - Is actual memory
Virtual Memory - Each process cant access direct physical memory, so it uses virtual memory. Each process have its own virtual space. Physical memory address space is mapped to virtual memory address space. It is sort of security restriction where process cant directly indulge with Physical RAM. MMU - Memory Management Unit does the mapping between physical address space to virtual address space. pmap 1 shows mapping between VAS to PAS.
pmap 1 - 1st column in virtual memory / 2nd column is Physical memory
Resint column when added comes out more then actual physical memory.
less /proc/1/smaps - It shows dirty read and dirty buffer

Architecture:
1. Free
2. Inactive Clean - File is opened but dint modify. It will read from disk always
3. Inactive dirty - File is opened and made some changes. It will be in RAM, if any power cut, there will be loss, so kernal keep pushing them to disk. BDI is responisble for moving dirty buffers to disk.
4. Inactive

No comments:

Post a Comment