Added memory profiling for debug.