Profiling memory use in Matlab

The post on http://undocumentedmatlab.com/blog/undocumented-profiler-options/ describes an undocumented option of the Matlab profiler that allows for measuring memory bottlenecks.

In short, you switch it on with


profile -memory on;
profile('-memory','on'); % alternative