Added middleware for logging memory usage (was in separate Memory_middleware repo)