A memory leak, technically, is an ever-increasing usage of memory by an application.
With common desktop applications, this may go unnoticed, because a process typically frees any memory it has used when you close the application.
However, In the client/server model, memory leakage is a serious issue, because applications are expected to be available 24×7. Applications must not continue to increase their memory usage indefinitely, because this can cause serious issues. To monitor such memory leaks, we can use the following commands.
$ ps aux --sort pmem USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.0 1520 508 ? S 2005 1:27 init inst 1309 0.0 0.4 344308 33048 ? S 2005 1:55 agnt (idle) inst 2919 0.0 0.4 345580 37368 ? S 2005 20:02 agnt (idle) inst 24594 0.0 0.4 345068 36960 ? S 2005 15:45 agnt (idle) root 27645 0.0 14.4 1231288 1183976 ? S 2005 3:01 /TaskServer/bin/./wrapper-linux-x86-32
In the above ps command, –sort option outputs the highest %MEM at bottom. Just note down the PID for the highest %MEM usage. Then use ps command to view all the details about this process id, and monitor the change over time. You had to manually repeat ir or put it as a cron to a file.
$ ps ev --pid=27645 PID TTY STAT TIME MAJFL TRS DRS RSS %MEM COMMAND 27645 ? S 3:01 0 25 1231262 1183976 14.4 /TaskServer/bin/./wrapper-linux-x86-32 $ ps ev --pid=27645 PID TTY STAT TIME MAJFL TRS DRS RSS %MEM COMMAND 27645 ? S 3:01 0 25 1231262 1183976 14.4 /TaskServer/bin/./wrapper-linux-x86-32
Note: In the above output, if RSS (resident set size, in KB) increases over time (so would %MEM), it may indicate a memory leak in the application.