“My game is slow” isn’t something you can fix. “EnemyAI.Update takes 6 ms because it calls FindObjectsByType every frame” is. The Unity Profiler is how you get from the first sentence to the second, and it’s already built into the editor. This beginner guide shows how to open it, read the CPU module, find the real bottleneck, profile a build instead of the Editor, spot garbage collection spikes, and mark up your own code so it shows up clearly. No prior profiling experience needed.
Opening the Profiler
Open Window > Analysis > Profiler (or Ctrl+7 / Cmd+7). Make sure the record button (the red circle) is on, then enter Play mode. The graphs start scrolling, with one column per frame.
Play until the slowdown happens, then pause the game (or click in the graph, which pauses recording on that frame). Click a tall spike in the chart. The bottom half of the window now shows exactly what happened during that single frame.
A useful habit: turn on the Stats overlay in the Game view to see the frame rate, and know your target first. At 60 FPS you have 16.7 ms per frame. At 30 FPS, 33.3 ms. Our frame-time budget guide explains how to split that time up.

The Modules at the Top
Each row at the top of the Profiler is a module. The main ones:
- CPU Usage: time spent per frame, split into categories (scripts, rendering, physics, animation, GC, VSync). Start here almost every time.
- GPU Usage: GPU time per frame. Not available on every platform or graphics API. Enable it from the Profiler Modules dropdown if it’s missing.
- Rendering: batches, draw calls (SetPass calls), triangles and vertices.
- Memory: total memory, textures, meshes, and GC allocations per frame.
- Physics, Audio, UI: detail for those systems.
Use the Profiler Modules dropdown to hide modules you don’t need. Fewer modules means less profiler overhead.
Reading the CPU Module
Select a frame, then look at the detail panel below. The dropdown at its top-left switches between views:
Hierarchy view
A sortable tree of everything that ran in the frame. The important columns:
| Column | Meaning |
|---|---|
| Total | Percentage of the frame spent in this item including its children |
| Self | Percentage spent in this item itself, excluding children |
| Calls | How many times it ran this frame |
| GC Alloc | Managed memory allocated this frame |
| Time ms / Self ms | The same as Total / Self, in milliseconds |
The workflow: sort by Time ms, expand the biggest item (usually PlayerLoop), and keep expanding the biggest child until you reach something you recognize: Update.ScriptRunBehaviourUpdate leads to BehaviourUpdate and then to your scripts, like EnemyAI.Update(). Then sort by Self ms to find the items that are expensive on their own rather than just containing expensive children.
Watch the Calls column. EnemyAI.Update at 0.02 ms per call is nothing, but with 500 calls it’s 10 ms. The fix might be fewer calls (one manager updating all enemies), not faster code.
Timeline view
Shows the same frame as horizontal bars on a time axis, per thread: main thread, render thread and job worker threads. Use it to see when things happen and whether the main thread is waiting on something else. It makes the CPU-bound versus GPU-bound question below easy to answer.
Deep Profile
By default, the Profiler shows Unity’s callbacks (Update, FixedUpdate) but not every method they call. Deep Profile (toolbar button) records every C# method call. It’s great for finding which helper method is slow, but it adds a lot of overhead and makes everything look slower than it is. Turn it on only to drill into a specific problem, then turn it off. Custom markers (below) are usually the better option.

CPU-Bound or GPU-Bound?
Before optimizing anything, find out which processor is the bottleneck. Optimizing scripts does nothing if the GPU is the limit, and vice versa. Look at what the main thread is waiting on in the CPU module:
Gfx.WaitForPresentOnGfxThreadorGfx.WaitForGfxCommandsFromMainThreadtaking a big chunk of the frame: the CPU is waiting for the GPU or render thread. You’re likely GPU-bound. Look at resolution, overdraw, shaders, post-processing, shadows and draw calls.WaitForTargetFPS: the frame finished early and Unity is idling to hit a target frame rate or VSync. That’s spare time, not a problem.- Scripts, physics or animation taking most of the frame: you’re CPU-bound. Work on the biggest items in the Hierarchy.
A quick GPU test: lower the resolution a lot (or the URP Render Scale). If the frame rate jumps, you’re GPU-bound. If it doesn’t change, you’re CPU-bound.
๐ What should each system cost?
The Profiler tells you where time goes. Our free calculator tells you how much time each system should get at 30, 60 or 120 FPS, so you know when a number is actually a problem.

What the Common Entries Mean
The Hierarchy is full of Unity’s own names, and beginners often waste time on rows that are harmless. These are the ones you’ll meet most often:
| Entry | What it is | What to do |
|---|---|---|
PlayerLoop |
Everything your game does in the frame | Expand it. This is where your real costs live. |
EditorLoop |
Editor work: Inspector, Scene view, windows | Ignore it for game performance. It doesn’t exist in builds. |
BehaviourUpdate |
All your MonoBehaviour Update methods |
Expand to see each script and its Calls count. |
FixedUpdate.PhysicsFixedUpdate |
The physics simulation step | Check how many times it ran this frame (see below). |
Canvas.SendWillRenderCanvases |
uGUI rebuilding canvas layouts and meshes | Something changed on a Canvas. Move often-changing UI onto its own Canvas. |
GC.Collect |
The garbage collector running | Don’t fix this row. Find what allocates (next section). |
WaitForJobGroupID |
The main thread waiting for job worker threads | Check the worker threads in Timeline view. |
WaitForTargetFPS |
Idle time padding to VSync or a target frame rate | Nothing. It’s spare time. |
The physics death spiral
Physics runs on a fixed timestep (0.02 seconds by default, set in Project Settings > Time > Fixed Timestep). If one frame takes a long time, Unity runs FixedUpdate several times in the next frame to catch up. That makes the next frame slow too, which needs even more catching up. In the Profiler this shows as FixedUpdate.PhysicsFixedUpdate with a Calls value of 2, 3 or more on slow frames. The cause is usually somewhere else entirely, so fix the original slow frame first. Maximum Allowed Timestep on the same settings page caps how much catching up Unity will do.
Finding Garbage Collection Spikes
Occasional big spikes on an otherwise smooth graph are often the garbage collector reclaiming memory. In the Hierarchy you’ll see GC.Collect or GC.Alloc entries during those frames.
To find the cause, sort a normal frame by the GC Alloc column. Anything allocating every frame will eventually trigger a collection. Common culprits:
- String building in Update:
scoreText.text = "Score: " + score;every frame. Only update text when the value changes. GetComponentcalls and LINQ queries in Update. Cache the results.new List<T>()or arrays every frame. Reuse one list and callClear().- Instantiate and Destroy for bullets and effects. Use object pooling.
- Unity APIs that return new arrays, like
Physics.RaycastAll. Use theNonAllocversions.
Finding the exact line that allocates
The GC Alloc column tells you which script allocates, but not which line. For that, open the Call Stacks dropdown in the Profiler toolbar, enable GC.Alloc, and record again. Switch the detail panel to Timeline, find a GC.Alloc sample on the main thread (they’re thin, so zoom in), and select it. The pop-up now shows the full call stack, down to your method. This costs far less than turning on Deep Profile for the whole capture.
Unity 6 uses the incremental garbage collector by default (Player Settings), which spreads collection over several frames and softens spikes. It helps, but reducing allocations is still the real fix.

Profiling a Real Build
The Editor is not your game. Profiling in Play mode includes Editor overhead (you’ll see EditorLoop taking time), runs your scripts with debugging enabled, and uses your development PC. Numbers from the Editor are fine for spotting obvious problems but can be badly misleading.
To profile a build:
- In File > Build Profiles, tick Development Build and Autoconnect Profiler.
- Build and run. For mobile, keep the device on the same network as your computer, or connected by USB.
- In the Profiler window, the target dropdown (next to the record button, usually saying “Play Mode”) lists running players. Select your build.
Always profile on your lowest target device. A game running at 200 FPS on your desktop can run at 25 on a mid-range phone.
Adding Your Own Markers
To see exactly how long a piece of your code takes without Deep Profile, wrap it in a ProfilerMarker. It has almost no cost, and it’s automatically compiled out of non-development builds.
using Unity.Profiling;
using UnityEngine;
public class EnemyManager : MonoBehaviour
{
static readonly ProfilerMarker s_PathMarker = new ProfilerMarker("Enemies.Pathfinding");
static readonly ProfilerMarker s_TargetMarker = new ProfilerMarker("Enemies.FindTargets");
void Update()
{
using (s_TargetMarker.Auto())
{
FindTargets();
}
using (s_PathMarker.Auto())
{
UpdatePaths();
}
}
void FindTargets() { /* ... */ }
void UpdatePaths() { /* ... */ }
}
“Enemies.Pathfinding” and “Enemies.FindTargets” now appear as their own entries in the Hierarchy and Timeline views. Use the Hierarchy’s search box to find them quickly.
You’ll also see older code use Profiler.BeginSample("Name") and Profiler.EndSample() from the UnityEngine.Profiling namespace. It does the same job, but every BeginSample needs a matching EndSample, including on early return paths, or the Profiler reports mismatched samples. The using (marker.Auto()) pattern closes itself, which is why it’s the safer choice for new code.
A Repeatable Profiling Routine
The Profiler is most useful as a before-and-after tool, not something you open once when things feel slow.
- Capture a baseline. Play the slow part of the game for a few seconds with recording on, then click Save in the Profiler toolbar. Unity writes a
.datafile you can reopen later with Load. - Find the single biggest item in a typical slow frame, using the Hierarchy routine above.
- Change one thing. If you change three things at once, you won’t know which one helped, or whether one made things worse.
- Capture again in the same place, with the same modules on. Turn on Clear on Play so old frames don’t mix in.
- Compare. For a quick check, look at the same entry in both captures. For anything more serious, load both files into the Profile Analyzer and compare median times across hundreds of frames, which smooths out one-off spikes.
If you can’t find the cause at all, narrow it down by elimination: disable half of the suspicious objects in the Hierarchy during Play mode and see whether the spikes stop. Keep halving until one object or system is left.
Capturing more frames
By default the Profiler keeps the most recent 300 frames, which is only five seconds at 60 FPS. A spike that happens once every ten seconds can scroll out of view before you notice it. Raise the limit under Edit > Preferences > Analysis > Profiler > Frame count (up to 2,000), or pause as soon as you feel the stutter.
Less Editor noise without making a build
When a full build is too slow to iterate on, open Window > Analysis > Profiler (Standalone Process). It runs the Profiler in a separate process, so the Profiler’s own drawing doesn’t land in your Play mode numbers. It still isn’t as accurate as a Development Build on the target device, but it’s closer than the docked window.
Related Tools
- Frame Debugger (Window > Analysis > Frame Debugger): steps through every draw call in a frame. Use it when you’re GPU-bound or have too many batches.
- Memory Profiler package: takes full memory snapshots and shows which textures, meshes and objects use memory, and compares two snapshots to find leaks.
- Profile Analyzer package: compares hundreds of frames or two captures (before and after an optimization) statistically, instead of eyeballing single frames.
Troubleshooting
The Profiler shows nothing or stays empty
Make sure recording is on (red circle), the target dropdown says Play Mode (or your build), and you’re in Play mode. Check that the CPU Usage module isn’t hidden in the Modules dropdown.
The build doesn’t appear in the target list
It must be a Development Build. Firewalls often block the connection. Allow Unity through the firewall, or enter the device IP with Direct Connection in the target dropdown. For Android, USB with adb is the most reliable.
EditorLoop takes most of the frame
That’s the Editor, not your game: Inspector repaints, Scene view rendering and so on. Close the Scene view, collapse the Inspector, or better, profile a build.
Everything is slower with the Profiler open
The Profiler has overhead, especially with Deep Profile and many modules. Compare relative numbers (this is 40% of the frame) rather than absolute ones, and turn off Deep Profile.
I can’t find my script in the Hierarchy
Use the search box, or look under PlayerLoop > Update.ScriptRunBehaviourUpdate > BehaviourUpdate. Only methods Unity calls directly appear without Deep Profile. Add a ProfilerMarker for anything else.
My earlier frames disappear when I press Play
Clear on Play is enabled. Turn it off if you want to keep a previous capture, or save it first.
The spike is too rare to catch
Raise the Frame count preference so more history is kept, and pause the game the moment you feel the hitch. A ProfilerMarker around the code you suspect also makes the right frame easy to find with the search box.
Still stuck? Check these
- You’re looking at
PlayerLoop, notEditorLoop. - You’ve checked the Calls column, not just the time per call.
- You know whether you’re CPU-bound or GPU-bound before changing anything.
- Deep Profile is off when you read real timings.
- You’ve confirmed the problem in a Development Build, not just the Editor.
- You changed only one thing between captures.
FAQ
How do I open the Profiler in Unity?
Window > Analysis > Profiler, or Ctrl+7 (Cmd+7 on Mac). Enter Play mode with recording on to capture frames.
Should I profile in the Editor or in a build?
Use the Editor for quick checks, but trust a Development Build on the target device for real numbers. The Editor adds overhead that doesn’t exist in builds.
What does Gfx.WaitForPresent mean?
The CPU is waiting for the GPU to finish the previous frame. A large value usually means you’re GPU-bound.
What is Deep Profile?
A mode that records every C# method call. It shows more detail but adds heavy overhead, so use it briefly or use ProfilerMarkers instead.
What is GC Alloc in the Profiler?
Managed memory allocated during that frame. Constant allocation leads to garbage collection spikes, so aim for zero GC Alloc in gameplay frames.
How do I compare two Profiler captures?
Save each capture as a .data file from the Profiler toolbar. Load them one at a time to check the same entry, or load both into the Profile Analyzer package to compare averages across many frames.
How do I find which line of code allocates garbage?
Enable Call Stacks > GC.Alloc in the Profiler toolbar, record, then select a GC.Alloc sample in the Timeline view to see its full call stack.
Does the Profiler work on mobile?
Yes. Make a Development Build with Autoconnect Profiler and connect over the network or USB from the Profiler’s target dropdown.
Reader questions
Asked by readers of this article and answered by AI. Behavior can differ between Unity versions, so test in yours.




Leave a Reply