Is there a way, I can find the memory leak of a running process? I can use Valgrind for finding memory leaks before the start of a process. I can use GDB to attach it to a running process. How could I debug a memory leaks of a running process?
On Linux, you could enable mtrace in your program, but it is a code change.
On OpenBSD, you could try the malloc stats.
Google's leak checker might also be worth a look, and unlike mtrace you may be able to use
I think without providing support for allocation monitoring after program start directly in the source code, you're out of luck. Here are two reasons I can think of:
If, however, you're program is running inside a virtual machine, that environment may provide support for monitoring allocations. I know Java has several allocation and garbage collection monitoring tools (like visualVM) that attach to running programs or VMs.