Diagnosing Memory Issues
------------------------
What is memory leak?
In computer science,
a memory leak is a type of resource leak that occurs when a
computer program
incorrectly manages memory allocations in such a way that
memory which is no
longer needed is not released. A memory leak may also happen
when an object is
stored in memory but cannot be accessed by the running code.
Finding top
consumers
|
ps --sort -rss -eo
rss,pid,command | head
|
User Processes
--------------
Process vs Threads:
Process is an
executing program and don't share memory spaces while threads are
contained inside a
process which shares memory space.
Threads are also
called LWP in linux. They also consume kernel.pid_max.
/proc/sys/kernel/pid_max
|
- number of PIDs
that can be created
- assigns sequentially, when limit is reached, counter wraps back to the beginning - if no available PID can be used, no more processes can be created |
Determining current
pid_max value
|
# using sar
see "plist-sz" of "sar -q" command # using ps (L is to see LWP or light-weight processes in multithreading systems) ps -eL | wc -l ps -eT | wc -l |
Determining number
of user processes
|
# via ps
ps h -Led -o user | sort | uniq -c | sort -n ps h -Lu root | wc -l |
CPU Loads
---------
Checking under
"sar -q"
|
- high
"runq-sz" means there's a lot of processes waiting in line
|