you can use mprof start, stop, snapshot commands to dump memory. build and run MomoryProfiler2 to view that dump. for your reference, see FMallocProfiler::HandleMProfCommand function.
source code path of MemoryProfiler2 is Engine\Source\Programs\MemoryProfiler2.
Don’t set the Macro to 1, use bUseMallocProfiler = true; in your game’s Target or you won’t be able to properly build UnrealHeaderTool (at least in the Switch toolchain)