This post provides great detail on how to integrate with gcc's malloc attribute and its equivalent functionality in msvc.
This could help with some diagnostics and/or optimizations.