You can do this with the latest version of Valgrind (3.8.1):
Run the executable by activating gdbserver at startup:
valgrind --vgdb-error=0 ....<your program>
Then in another window, connect gdb to Valgrind (following the instructions given by Valgrind). Then set a breakpoint in the appropriate place (for example, at the end of the main one) and use gdb
continue
before reaching the breakpoint. Then do a leak search from gdb:
monitor leak_check full reachable any
Then list the addresses of the reachable blocks of the corresponding loss record nr
monitor block_list <loss_record_nr>
Then you can use the gdb functions to check the memory with the specified addresses. Pay attention also to the potentially interesting command "who_points_at" if you are looking for who saved a pointer to this memory.
source share