Version: 2021.3
言語: 日本語

説明

Use to sum all samples within a frame and collect those as one sample per frame.

using System;
using Unity.Profiling;
using UnityEngine;

public class CollectGCAllocCountExample2 { static void PrintGCAllocCount(Action a) { using (var gcAllocRecorder = ProfilerRecorder.StartNew(ProfilerCategory.Internal, "GC.Alloc", 1, ProfilerRecorderOptions.SumAllSamplesInFrame | ProfilerRecorderOptions.CollectOnlyOnCurrentThread)) { a.Invoke();

gcAllocRecorder.Stop();

var count = gcAllocRecorder.Count == 0 ? 0 : gcAllocRecorder.GetSample(0).Count; Debug.Log("GC allocs count: " + count); } } }