I have written a C++ application, that runs forever until terminated manually. It monitors other important applications. As a result my Daemon application should not go down. Keeping that in mind, I want to see if there are any memory leaks in my application. I used valgrind but since this application keeps running forever the valgrind does not exit. if I do a control - C then I don't get complete info from the valgrind logfile.
Is there a tool that can do what Valgrind does?
I believe you can connect gdb to a running valgrind process, and instruct it to run a leak check explicitly.
I haven't tried this, just seen it in the docs.
In case of link breakage:
$ valgrind --tool=memcheck --vgdb=yes --vgdb-error=0 ./prog
(the error parameter is the number of errors before the gdbserver becomes active: zero means it starts running right away).
Then start gdb on your program and connect to the remote target
$ gdb ./prog
(gdb) target remote | vgdb
and to trigger the check
(gdb) monitor leak_check full reachable any
See your docs or the linked ones for full details.