if in lazarus then project options>linking> check 'use heaptrc', usefull for tracking memory leaks