Dear CentOS people,
This is just a general question related to memory management, and there may have been a thread or two about it before, but I'd like to post anyway.
A user was looking at top, whereby he found out that his two processes were 10.2g and 4836m in VIRT. They were 6.4g and 4.6g in RES respectively. 3445964k was free still. He was wondering why the system didn't use all of the physical memory available (16300960k total) before swapping out parts of the processes.
Over time, the 10.2g process had about 8g of it in SWAP. The 4836m process only had about 100m in SWAP. Much of the physical space is now used.
I guess the answer may not be that simple and I most likely haven't described everything that could have influenced the kernel's decision-making, but how does Linux decide how much of a process to be swapped out? I guess I could read the documentations on the Linux kernel, but does anyone have more general answers ready to be dispensed?
I haven't done anything with sysctl, if that comes into play at all.
Thank you,
--Koji
yanagik317 wrote:
I guess the answer may not be that simple and I most likely haven't described everything that could have influenced the kernel's decision-making, but how does Linux decide how much of a process to be swapped out? I guess I could read the documentations on the Linux kernel, but does anyone have more general answers ready to be dispensed?
Linux by default will try to swap less accessed regions of memory when memory pressure starts to get tight(say less than 25% of memory is free), if you want to override this behavior look to the 'swappiness' setting
I haven't done anything with sysctl, if that comes into play at all.
It can if you want
vm.swappiness = 0
To tell the kernel not to swap unless it *really* needs to
nate
nate wrote:
yanagik317 wrote:
I guess the answer may not be that simple and I most likely haven't described everything that could have influenced the kernel's decision-making, but how does Linux decide how much of a process to be swapped out? I guess I could read the documentations on the Linux kernel, but does anyone have more general answers ready to be dispensed?
Linux by default will try to swap less accessed regions of memory when memory pressure starts to get tight(say less than 25% of memory is free), if you want to override this behavior look to the 'swappiness' setting
I haven't done anything with sysctl, if that comes into play at all.
It can if you want
vm.swappiness = 0
To tell the kernel not to swap unless it *really* needs to
Also, the top values may not tell the whole story - RES should include paged-in code plus memory allocated by the program. VIRT includes code not paged in yet and linked shared libraries, so the difference may not all be in swap.
Also, the top values may not tell the whole story - RES should include paged-in code plus memory allocated by the program. VIRT includes code not paged in yet and linked shared libraries, so the difference may not all be in swap.
I thought I remembered reading (maybe LKML) that RES also didn't account for the COW efficiency of shared libraries. Meaning RES could potentially show a value which is larger than actual physical memory used. Sorry if I'm spreading misinformation :)
Thanks.