Add support for memory profiling. Closes #105