Version: 2017.1

Profiler.GetTotalReservedMemoryLong

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

返回

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

描述

Unity 预留的总内存。

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

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void Update() { Debug.Log("Total Reserved memory by Unity: " + Profiling.Profiler.GetTotalReservedSizeLong() + "Bytes"); Debug.Log("- Allocated memory by Unity: " + Profiling.Profiler.GetTotalAllocatedSizeLong() + "Bytes"); Debug.Log("- Reserved but not allocated: " + Profiling.Profiler.GetTotalUnusedReservedLong() + "Bytes"); } }