Attach to a running process with
gdb -x trace-dyn-mem -p $PID
After every malloc
the returned value (the allocated address) will be read from the RAX (64 bits) register.
After every free
the last item in the backtrace (the free
itself) will be shown. With the libc6-dbg
package installed you can see the address passed as the first argument of free
.