Blog

Unity Performance Optimization Checklist: Profiler, GC, Rendering

A practical Unity performance optimization checklist: profile first, stop per-frame allocations, simplify colliders, cut draw calls and trim builds.

Unity Performance Optimization Checklist: Profiler, GC, Rendering

A good Unity performance optimization checklist has five steps, in this order: measure with the Profiler on the target device, stop allocating managed memory every frame, keep physics colliders far simpler than the visual meshes, cut the CPU cost of rendering (batching, SRP Batcher, instancing, LOD, atlases, overdraw), and only then trim builds and assets. In our experience most slow Unity games are slow for two boring reasons: code that creates garbage every frame, and physics that collides against detailed render meshes. Fix those two and many projects hit their frame budget before anyone touches a shader.

This guide walks through each step with concrete settings and short C# examples of allocation-free patterns. Facts about Unity versions are as of November 2026, when Unity 6.3 is the current LTS and Unity 6.6 is the latest supported release.

Step 1: Profile Before You Optimize

Never optimize from a hunch. Open Window > Analysis > Profiler, build a Development Build with Autoconnect Profiler enabled, and profile on the slowest device you plan to support. The Editor adds its own overhead, so an Editor capture is fine for spotting a hot method but not for deciding whether a frame fits its budget.

Start from the budget. At 60 FPS a frame has about 16.6 ms; at 30 FPS about 33.3 ms. On mobile, leave headroom for thermal throttling and aim lower than the theoretical budget.

  • If the CPU main thread is the long bar, you are CPU-bound: scripts, physics, animation, or the cost of submitting draw calls.
  • If the main thread waits on the render thread or on Gfx.WaitForPresent, you are likely GPU-bound: fill rate, overdraw, heavy shaders, too many pixels.
  • If frame time is fine on average but spikes every few seconds, look at GC.Collect and GC.Alloc first.

Useful tools, all from Unity itself:

  • The CPU Usage module with the Hierarchy view, sorted by Self ms, to find the expensive methods.
  • The GC Alloc column in the same view, to find who allocates every frame.
  • The Frame Debugger (Window > Analysis > Frame Debugger), to see every draw call and why batches break.
  • The Memory Profiler package, to find textures, meshes and audio clips that are larger than they should be.
  • Profiler markers around your own code, so your systems show up by name.
C#EnemyManager.cs
using Unity.Profiling;
using UnityEngine;

public class EnemyManager : MonoBehaviour
{
    // Created once; Begin/End do not allocate.
    static readonly ProfilerMarker s_UpdateEnemies = new ProfilerMarker("EnemyManager.UpdateEnemies");

    void Update()
    {
        using (s_UpdateEnemies.Auto())
        {
            // ... update all enemies here ...
        }
    }
}

Write down the numbers before every change and measure again after it. An optimization you cannot measure is a guess, and guesses add complexity without a guaranteed win.

Step 2: Stop Allocating Memory Every Frame

This is our first rule and the one we see broken most often: code should manage memory well and not allocate new managed memory every frame. Every allocation on the managed heap eventually has to be collected. A few kilobytes per frame look harmless, but at 60 FPS they become megabytes per minute, and the garbage collector then pauses the game to clean up.

Unity enables incremental garbage collection by default (Project Settings > Player > Other Settings > Configuration > Use Incremental GC). It spreads collection work over several frames, which reduces spikes, but it does not make collection free, and it adds write-barrier overhead. Unity's manual also notes that the CoreCLR scripting back end and the Web platform do not support incremental GC. The only reliable fix is to allocate less.

The target we recommend: zero bytes in the GC Alloc column for your gameplay code during normal play. Allocate at load time, during level transitions, or behind a loading screen.

Common Per-Frame Allocations

  • String concatenation and formatting in Update (score labels, debug text).
  • LINQ queries and lambdas that capture local variables.
  • new List or new array inside a method that runs every frame.
  • Physics queries that return arrays, such as Physics.RaycastAll and Physics.OverlapSphere.
  • GetComponents and FindObjectsByType called every frame.
  • Boxing: passing a struct or an enum where an object is expected.
  • Instantiate and Destroy for bullets, particles and pickups.
  • Accessing mesh.vertices or similar array properties, which return a fresh copy on every call.

Reuse Buffers Instead of Creating Them

Allocate a buffer once and reuse it. The non-allocating physics APIs write into an array you own and return how many results they found.

C#ProximitySensor.cs
using UnityEngine;

public class ProximitySensor : MonoBehaviour
{
    [SerializeField] float radius = 5f;
    [SerializeField] LayerMask enemyMask;

    // Allocated once, reused every frame.
    readonly Collider[] _hits = new Collider[32];

    void FixedUpdate()
    {
        int count = Physics.OverlapSphereNonAlloc(transform.position, radius, _hits, enemyMask);
        for (int i = 0; i < count; i++)
        {
            // React to _hits[i]; no new array was created.
        }
    }
}

The same idea works for lists: keep one List as a field and call Clear instead of creating a new one. Many Unity APIs accept a list to fill, such as GetComponents with a List argument.

Cache Hashes, Components and Strings

Looking things up by string is slow and sometimes allocates. Hash names once, cache components once, and only rebuild text when the value changes.

C#PlayerHud.cs
using TMPro;
using UnityEngine;

public class PlayerHud : MonoBehaviour
{
    static readonly int SpeedId = Animator.StringToHash("Speed");
    static readonly int TintId = Shader.PropertyToID("_BaseColor");

    [SerializeField] Animator animator;
    [SerializeField] Renderer body;
    [SerializeField] TMP_Text scoreLabel;

    MaterialPropertyBlock _block;
    int _shownScore = -1;

    void Awake() => _block = new MaterialPropertyBlock();

    public void Refresh(float speed, int score, Color tint)
    {
        animator.SetFloat(SpeedId, speed);

        body.GetPropertyBlock(_block);
        _block.SetColor(TintId, tint);
        body.SetPropertyBlock(_block);

        // Rebuild the string only when the number changes.
        if (score != _shownScore)
        {
            _shownScore = score;
            scoreLabel.SetText("Score: {0}", score);
        }
    }
}

Two more habits: use CompareTag instead of comparing gameObject.tag with ==, because reading the tag property allocates a string, and avoid Camera.main in hot loops on older Unity versions; cache it in a field.

Pool Objects Instead of Instantiate and Destroy

Unity ships a generic pool in UnityEngine.Pool. Pre-warm it during loading and reuse instances during play.

C#BulletSpawner.cs
using UnityEngine;
using UnityEngine.Pool;

public class BulletSpawner : MonoBehaviour
{
    [SerializeField] Bullet prefab;
    ObjectPool<Bullet> _pool;

    void Awake()
    {
        _pool = new ObjectPool<Bullet>(
            createFunc: () => Instantiate(prefab),
            actionOnGet: b => b.gameObject.SetActive(true),
            actionOnRelease: b => b.gameObject.SetActive(false),
            actionOnDestroy: b => Destroy(b.gameObject),
            defaultCapacity: 64,
            maxSize: 256);
    }

    public void Fire(Vector3 position, Quaternion rotation)
    {
        Bullet bullet = _pool.Get();
        bullet.transform.SetPositionAndRotation(position, rotation);
        bullet.Init(_pool); // the bullet calls pool.Release(this) when it hits
    }
}

The lambdas here are created once in Awake, not every frame, so they cost nothing during play. For hot loops over thousands of elements, consider structs in a NativeArray with the Burst compiler and the job system; that is a bigger change, so make it only where the Profiler proves the loop matters.

Step 3: Keep Physics Colliders Much Simpler Than the Meshes

Our second rule: physics colliders should be much simpler than the visual meshes. A character with a 40,000-triangle mesh does not need a 40,000-triangle collider. Physics cost grows with collider complexity, and a detailed MeshCollider on a moving object is one of the most expensive things you can put in a scene.

What we recommend, from cheapest to most expensive:

  • Sphere and capsule colliders for characters, projectiles and pickups.
  • Box colliders for crates, walls, doors and most props.
  • A few primitives combined on child objects (a compound collider) for complex shapes such as vehicles.
  • A convex MeshCollider built from a separate low-poly mesh (tens or a few hundred triangles), only when primitives cannot fit the shape.
  • A non-convex MeshCollider only for static level geometry, and even then from a simplified collision mesh, not the render mesh.

More physics settings worth checking:

  • Set the Layer Collision Matrix (Project Settings > Physics) so layers that never interact never test each other.
  • Check Fixed Timestep (Project Settings > Time, 0.02 s by default). A smaller step means more physics updates per second and more CPU time.
  • Pass a LayerMask and a max distance to every raycast.
  • Move Rigidbody objects with Rigidbody.MovePosition, not by setting transform.position, which forces extra synchronisation.
  • Keep Auto Sync Transforms disabled unless you rely on it.
  • Mark objects that never move as static, so their colliders are not treated as moving.

A quick audit tells you where you stand: list every MeshCollider in the scene, its triangle count, and whether its object has a Rigidbody. Anything non-convex and moving, or anything that reuses the render mesh, goes to the top of the fix list.

Step 4: Reduce Rendering Cost

Rendering cost has two sides. The CPU prepares and submits draw calls; the GPU shades pixels. The Profiler tells you which one is your problem, and the fixes differ.

Cut CPU Cost: Batching and the SRP Batcher

  • Use the SRP Batcher in URP and HDRP. It is enabled on the render pipeline asset and makes repeated draws with the same shader variant much cheaper. Check in the Frame Debugger that your shaders are compatible; custom shaders must put material properties in a single constant buffer.
  • Share materials. Every unique material and shader variant can break a batch. Use a MaterialPropertyBlock or a shared material with a texture atlas instead of cloning materials per object. Note that accessing renderer.material creates a copy; use renderer.sharedMaterial when you only read.
  • Use GPU instancing for many copies of the same mesh with the same material (grass, rocks, crowds). Unity's GPU instancing does not combine with the SRP Batcher on the same renderer, so pick per case and measure.
  • Use static batching for level geometry that never moves, if memory allows: it trades memory for fewer draw calls.
  • In Unity 6 URP, try the GPU Resident Drawer for scenes with many static Mesh Renderers. As of November 2026 Unity's documentation says it needs the Forward+ rendering path and a graphics API with compute shader support (not OpenGL ES). To enable it, set BatchRendererGroup Variants to Keep All under Project Settings > Graphics, keep the SRP Batcher enabled on the URP asset, set GPU Resident Drawer to Instanced Drawing, and set the Universal Renderer to Forward+. Unity notes that build times grow, and that a GPU-bound app may see higher frame times, so measure before and after.

Cut GPU Cost: LOD, Atlases and Overdraw

  • Add LOD Groups to detailed meshes so distant objects draw with fewer triangles, and set a cull distance for small props.
  • Pack UI sprites and small textures into atlases (Sprite Atlas for 2D and UI). Fewer textures means fewer batch breaks and fewer texture switches.
  • Watch overdraw: large transparent particles, stacked UI panels and full-screen effects shade the same pixel many times. Use the Scene view Overdraw mode in the built-in pipeline or the Rendering Debugger in URP to find it.
  • Prefer opaque or alpha-tested materials where the look allows; transparency cannot use early depth rejection.
  • Enable occlusion culling for indoor levels with many hidden objects.
  • Limit real-time shadows: lower shadow distance, fewer shadow-casting lights, and disable Cast Shadows on small objects.
  • Lower the render scale on mobile and let the UI render at native resolution.
  • Split UI canvases so that a changing label does not rebuild a static panel.

Step 5: Build and Asset Settings

Build settings decide load times, memory use and download size. They rarely fix a frame-rate problem on their own, but they often fix memory crashes on mobile.

  • Use IL2CPP for release builds on platforms that support it, and set Managed Stripping Level to strip unused code (test after raising it, because reflection-heavy code can break).
  • Compress textures with the platform's format (ASTC on modern mobile, BC on desktop) and set a sensible Max Size per texture, not 4096 by default.
  • Disable Read/Write on meshes and textures that scripts never read; it keeps a second copy in CPU memory.
  • Generate mipmaps for 3D textures and disable them for UI.
  • Import long music as Streaming and short sound effects as Decompress On Load or Compressed In Memory.
  • Use Mesh Compression and Optimize Mesh Data where precision allows.
  • Load content on demand with Addressables instead of putting everything in Resources.
  • Strip unused shader variants; they cost build time and memory.
  • Use the Build Report or the Memory Profiler to find the largest assets, then fix the top ten.

The Unity Performance Optimization Checklist in Short

Copy this into your task tracker and tick it per release:

  1. Set a frame budget and profile a Development Build on the slowest target device.
  2. Add ProfilerMarkers around your own systems.
  3. Get gameplay GC Alloc to zero bytes per frame: no strings, LINQ, new collections or boxing in Update.
  4. Use NonAlloc physics queries, cached hashes and cached components.
  5. Pool bullets, effects and pickups with ObjectPool.
  6. Replace detailed MeshColliders with primitives or simplified convex meshes.
  7. Configure the Layer Collision Matrix and check Fixed Timestep.
  8. Enable the SRP Batcher, share materials and verify batches in the Frame Debugger.
  9. Use GPU instancing or the GPU Resident Drawer where they measurably help.
  10. Add LOD Groups, atlases and occlusion culling; reduce overdraw and shadows.
  11. Compress textures and audio per platform, disable Read/Write, and strip unused code and shaders.
  12. Measure again and keep the numbers with the commit.

Let an AI Agent Do the Tedious Audits

Much of this checklist is mechanical: find every MeshCollider on a moving object, find materials that break batches, find textures without compression, read the Profiler after a play session. That is exactly the kind of work an AI agent connected to the editor does well.

AI Game Developer connects agents such as Claude Code to the live Unity Editor (ai-game.dev/engines/unity). Through RQL the agent can query the scene's GameObjects and components, and the profiler source exposes memory, rendering, script and frame snapshots with calls to start and stop recording, save and load captures. The agent can also write a short C# snippet and run it immediately inside the editor, for example to list every non-convex MeshCollider with a Rigidbody, and then fix what it finds. The setup is described in ai-game.dev/blog/claude-code-unity-tutorial, and the full tool list is at ai-game.dev/docs/tools/unity.

Keep the human in charge of the decisions: the agent can find and fix the obvious problems quickly, but trade-offs such as visual quality against frame rate stay yours. Download the app at ai-game.dev/download.

More from the blog

All posts