NOA DebuggerNOA Debugger
  • v1.7.0
  • v1.6.1
  • v1.5.0
  • v1.4.0
  • v1.3.0
  • v1.2.0
  • v1.1.1
  • v1.0.0
Demo
Contact
Buy
  • 日本語
  • English
  • 日本語
  • English
  • 日本語
  • English
  • 日本語
  • English
  • 日本語
  • English
  • 日本語
  • English
  • 日本語
  • English
  • 日本語
  • English
  • v1.7.0
  • v1.6.1
  • v1.5.0
  • v1.4.0
  • v1.3.0
  • v1.2.0
  • v1.1.1
  • v1.0.0
Demo
Contact
Buy
  • 日本語
  • English
  • 日本語
  • English
  • 日本語
  • English
  • 日本語
  • English
  • 日本語
  • English
  • 日本語
  • English
  • 日本語
  • English
  • 日本語
  • English
  • NoaGCCollectCallbacks

NoaGCCollectCallbacks

Configure events related to garbage collection executed by NOA Debugger.

By passing a class that inherits NoaGCCollectCallbacks to NoaProfiler, you can customize events related to garbage collection.

Overridable Members

Methods

NameDescription
OnBeforeGCCollect()Executed before the garbage collection process.
OnAfterGCCollect()Executed after the garbage collection process. Executed even if NOA Debugger’s garbage collection process was not executed.

Properties

NameDescription
IsAllowBaseGCCollectDetermines whether to execute NOA Debugger’s garbage collection process. Default is true; if set to false, the garbage collection process is not executed.

Related Types

INoaGCCollectCallbacks

The overridable methods and properties of NoaGCCollectCallbacks are defined in this interface.

If you want to consolidate multiple callback definitions in a custom class, or add callback functionality while inheriting an existing custom class, you can achieve this by using this interface instead of the NoaGCCollectCallbacks class.

Sample Code

#if NOA_DEBUGGER
using NoaDebugger;
using System;
using UnityEngine;

// Example of executing events before and after NOA Debugger’s garbage collection process.
public class ExampleGCCollector : NoaGCCollectCallbacks
{
    // Example of logging memory usage before and after garbage collection.
    public override void OnBeforeGCCollect()
    {
        Debug.Log($"Memory before GC: {GC.GetTotalMemory(false)} bytes");
    }

    public override void OnAfterGCCollect()
    {
        Debug.Log($"Memory after GC: {GC.GetTotalMemory(false)} bytes");
    }
}

// Example of controlling whether to execute NOA Debugger’s garbage collection process with a custom flag.
public class ExampleOriginalGCCollector : NoaGCCollectCallbacks
{
    bool isAllowBaseGCCollect = true;
    public override bool IsAllowBaseGCCollect => isAllowBaseGCCollect;

    // Example of setting a fixed interval for garbage collection execution.
    float lastGCCollectTime = 0.0f;
    const float gcCollectInterval = 5.0f;

    public override void OnBeforeGCCollect()
    {
        float currentTime = Time.realtimeSinceStartup;
        if (currentTime - lastGCCollectTime < gcCollectInterval)
        {
            isAllowBaseGCCollect = false;
        }
        else
        {
            isAllowBaseGCCollect = true;
            lastGCCollectTime = currentTime;
        }
    }
}
#endif

Links

Related Features

  • Profiler

Classes Used

  • NoaProfiler