When we say there is a memory leak, does that mean a leak in the virtual memory or in the physical memory? I feel like its actually a leak in the VM in the sense that only virtual memory space is wasted because anyway the physical memory is saved by swapping out the unused pages. But it still wastes the VM space. Please clarify.
Is it possible to use the linux top command and tell there could possibly be a memory leak?
Virtual memory is essentially (in a practical sense) the same as physical memory, just extended to the system’s disk drive for caching purposes (see paging files). Since it is on the disk, it is much slower to access since the data will need to be ‘swapped’ out from the disk to physical memory before it is read. If a program has a memory leak, it will fill up both (or at least to the limit of the memory available to the program.)
You can use top to check the processes which are consuming a lot of memory. If the amount of memory continues to grow in a program at an abnormal rate, then that might be an indication of a memory leak. It would be more readily identifiable with programs like valgrind: http://en.wikipedia.org/wiki/Valgrind