Version: 2020.3
public void Dispose ();

描述

Releases unmanaged instance of the ProfilerRecorder.

When you no longer need to use the ProfilerRecorder always use this method to safely release the instance of it.

using Unity.Profiling;
using UnityEngine;

public class ExampleScript : MonoBehaviour { ProfilerRecorder systemMemoryRecorder; ProfilerRecorder gcMemoryRecorder; ProfilerRecorder mainThreadTimeRecorder;

void OnEnable() { systemMemoryRecorder = new ProfilerRecorder(ProfilerCategory.Memory, "System Used Memory", 1, ProfilerRecorderOptions.Default | ProfilerRecorderOptions.StartImmediately); gcMemoryRecorder = new ProfilerRecorder(ProfilerCategory.Memory, "GC Reserved Memory", 1, ProfilerRecorderOptions.Default | ProfilerRecorderOptions.StartImmediately); mainThreadTimeRecorder = new ProfilerRecorder(ProfilerCategory.Internal, "Main Thread", 15); mainThreadTimeRecorder.Start(); }

void OnDisable() { systemMemoryRecorder.Dispose(); gcMemoryRecorder.Dispose(); mainThreadTimeRecorder.Dispose(); } }