I think I may have a memory leak in my LAMP application (memory gets used up, swap starts getting used, etc.). If I could see how much memory the various processes are using, it might help me resolve my problem. Is there a way for me to see this information in *nix?
Share
Getting right memory usage is trickier than one may think. The best way I could find is:
Where “PROCESS” is the name of the process you want to inspect and “TYPE” is one of:
Rss: resident memory usage, all memory the process uses, including all memory this process shares with other processes. It does not include swap;Shared: memory that this process shares with other processes;Private: private memory used by this process, you can look for memory leaks here;Swap: swap memory used by the process;Pss: Proportional Set Size, a good overall memory indicator. It is the Rss adjusted for sharing: if a process has 1MiB private and 20MiB shared between other 10 processes, Pss is 1 + 20/10 = 3MiBOther valid values are
Size(i.e. virtual size, which is almost meaningless) andReferenced(the amount of memory currently marked as referenced or accessed).You can use
watchor some other bash-script-fu to keep an eye on those values for processes that you want to monitor.For more informations about
smaps: http://www.kernel.org/doc/Documentation/filesystems/proc.txt.