Free Pascal provides a unit that allows you to trace allocation and deallocation of heap memory: heaptrc.
If you specify the -gh switch on the command line, the memory manager will trace what is allocated and deallocated, and on exit of your program, a summary will be sent to standard error.
More information on using the heaptrc mechanism can be found in the User’s Guide and Unit Reference.