detect memory leak with htop detect memory leak with htop unix unix

detect memory leak with htop


That isn't the ps command. It is the top or htop command. Do you have an alias set?

The VIRT column is all virtual memory and page files associated with the task, including libraries, and memory allocated but not used. RES is the physical memory currently in use. SHR is the memory that could be shared with other processes, such as shared libraries.

For more information or detail on these commands type:

man top

At your terminal. Then you can use / to search for your text.

EDIT:

Just a quick heads up for anyone who comes across this later, I found a program on freshmeat called memtime, which allows you to see the memory used for a command you run. That would solve your problem, without needing to manually watch the program with htop.


VIRT stands for the virtual size of a process, which is the sum of memory it is actually using, memory it has mapped into itself (for instance the video card's RAM for the X server), files on disk that have been mapped into it (most notably shared libraries), and memory shared with other processes. VIRT represents how much memory the program is able to access at the present moment. RES stands for the resident size, which is an accurate representation of how much actual physical memory a process is consuming. (This also corresponds directly to the %MEM column.) This will virtually always be less than the VIRT size, since most programs depend on the C library.

SHR indicates how much of the VIRT size is actually sharable memory or libraries). In the case of libraries, it does not necessarily mean that the entire library is resident. For example, if a program only uses a few functions in a library, the whole library is mapped and will be counted in VIRT and SHR, but only the parts of the library file containing the functions being used will actually be loaded in and be counted under RES.


Memory leaks by definition cannot be exposed by one snapshot. When you leak memory, your process uses more memory over time. While 373M virtual may seem high, unless you gain more and more memory without the application doing anything that should increase it's memory usage you cannot say you have a leak. If you suspect you have a leak you may want to look into using Valgrind.