Can I get the "Total Allocated" memory from script?

It seems like “UnityEngine.Profiler.GetTotalAllocatedMemory()” does not report nearly all allocated memory.

I would like to get a total memory consumption of my app from script.

Please do not suggest using an external profiler such as instruments.

Just for context. This is for automation.

Thanks,
Jonas

Ok, I solved it with by making a native-plugin, like so:


// inspired by:
// http://forum.sparrow-framework.org/topic/checking-device-memory-and-current-running-process
    
#import < mach/mach.h >
    
extern "C" int getMemoryUsage(){
    	struct task_basic_info info;
    	mach_msg_type_number_t size = sizeof(info);
    	kern_return_t kerr = task_info( mach_task_self(), TASK_BASIC_INFO, (task_info_t)&info, &size);
    
    	if( kerr == KERN_SUCCESS ) return (int)info.resident_size;
    	else return 0;
}