from Use C++ "new" and "delete" in MATLAB MEX files by Petter
This code modífies "new" and "delete" to register all allocated memory with the memory manager.

make.m
mex demomex.cpp newdelete.cpp

Contact us at files@mathworks.com