Profiler.enableAllocationCallstacks

Switch to Manual
public static bool enableAllocationCallstacks ;

Description

Enables the recording of callstacks for managed allocations.

When enabled, the Unity player saves callstack for each managed allocation sample which is known as GC.Alloc. You can see the callstacks in the Timeline View or in the Object Details pane of the Hierarchy View when selecting the GC.Alloc sample.

You must also set Profiler.enabled to true in order to start the capture.

using UnityEngine;
using System.Collections;
using UnityEngine.Profiling;

public class ExampleClass : MonoBehaviour { void Start() { Profiler.logFile = "mylog"; //Also supports passing "myLog.raw" Profiler.enableBinaryLog = true; Profiler.enableAllocationCallstacks = true; Profiler.enabled = true;

// Optional, if more memory is needed for the buffer Profiler.maxUsedMemory = 256 * 1024 * 1024; } }

Note: Callstacks capture adds noticable performance overhead to the profiling for every managed allocation.

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961