Search This Blog

Showing posts with label processes. Show all posts
Showing posts with label processes. Show all posts

2015-01-20

Linux Out Of Memory Management (Killer)

A summary of what an out of memory condition is is as follows:
  • Linux over allocates memory to processes VSZ giving them more than what they need.
  • It overcommits this memory allowing a larger VSZ than total memory availble
  • This generally isnt a problem since linux doesnt generally use up all the allocated memory
  • If processes actually require more memory than is available (due to their over allocation) it will kill "unimportant" processes to free memory and keep the system running

The messages for OOM killer can be found in:
/var/log/messages
Normally with the following keywords:
Out of Memory: Killed process

There are methods to mitigate the actions of OOM killer to prevent it from killing certain processes which can be found: http://unix.stackexchange.com/questions/136291/will-linux-start-killing-my-processes-without-asking-me-if-memory-gets-short/136294#136294 and here http://www.oracle.com/technetwork/articles/servers-storage-dev/oom-killer-1911807.html

The OOM calculator calculates using the following method: http://unix.stackexchange.com/questions/153585/how-oom-killer-decides-which-process-to-kill-first

References:
http://en.wikipedia.org/wiki/Out_of_memory

Memory Management In Linux

Using ps we can find out how much memory is allocated to a process (VSZ) and how much memory a process is actually using (RSS)

ps -e -o pid,vsz,rss,comm= | sort -n -k 2

The above will show you the process id, how much memory is allocated to a process, how much the process is actually using, and a comment of process description. It will then sort by how much memory is allocated to a process for you to see which apps are using up a lot of VSS.

Long running processes are useful to know as well when looking for memory hungry apps that have been running a long time

ps -ef --sort=start_time


References:
http://linuxconfig.org/ps-output-difference-between-vsz-vs-rss-memory-usage
http://serverfault.com/questions/27887/how-to-sort-ps-output-by-process-start-time
http://linuxcommando.blogspot.ca/2008/09/how-to-get-process-start-date-and-time.html