Skip to content

Instantly share code, notes, and snippets.

@luoyikun
luoyikun / AllocCounter.cs
Created May 23, 2026 14:42 — forked from adammyhre/AllocCounter.cs
Allocation Analyzer
using System;
using UnityEngine.Profiling;
// See UnityEngine.TestTools.Constraints.AllocatingGCMemoryConstraint
// and https://maingauche.games/devlog/20230504-counting-allocations-in-unity/
public class AllocCounter {
UnityEngine.Profiling.Recorder rec;
public AllocCounter() {
rec = Recorder.Get("GC.Alloc");