Version: 2020.2

Profiler.GetTotalReservedMemoryLong

切换到手册
public static long GetTotalReservedMemoryLong ();

返回

long Unity 预留的内存(以字节为单位)。如果性能分析器不可用,则返回 0。

描述

Unity 预留的总内存。

此函数返回 Unity 为当前和未来分配预留的内存总量。如果预留内存已用尽,Unity 会根据需要从系统中分配更多内存。

using UnityEngine;
using UnityEngine.Profiling;

public class Example : MonoBehaviour { void Update() { Debug.Log("Total Reserved memory by Unity: " + Profiler.GetTotalReservedMemoryLong() + "Bytes"); Debug.Log("- Allocated memory by Unity: " + Profiler.GetTotalAllocatedMemoryLong() + "Bytes"); Debug.Log("- Reserved but not allocated: " + Profiler.GetTotalUnusedReservedMemoryLong() + "Bytes"); } }