# Profiling and Optimization
Guessing is not a performance strategy. This series is a working method: **measure a development build on the target device**, read the **Profiler**, **Memory Profiler** and **Frame Debugger**, change one thing, and measure again. It ends with Meta's published Quest budgets, because a frame that is comfortable in the Editor can still miss 72 FPS on a Quest 2.
**Target:** Unity **6000.5+**. Quest and VR notes target **Unity 6.3 LTS (6000.3.27f2+)** ([[0.Choosing a Unity Version]], [[5.Quest 2 Performance and Rendering]]).
> [!warning] Code not compiled
> Scripts in this series were checked against the Unity 6000.5 Scripting API and package pages on 2026-11-10 but **have not been compiled or profiled in Unity**. Capture numbers from *your* project; do not treat the Quest tables as promises.
> [!note] Verification status
> **Versions (2026-11-10):** Memory Profiler (`com.unity.memoryprofiler`) **1.1.12** is released for 6000.5; **1.2.0** is also listed as released and available. Profile Analyzer (`com.unity.performance.profile-analyzer`) **1.4.2** is released for 6000.5. Profiling Core API (`com.unity.profiling.core`) **1.0.3** is released for 6000.5. The Profiler and Frame Debugger are built into the Editor (Window > Analysis).
> **Verified:** Frame Debugger enable flow and Render Graph event names from the 6000.5 Frame Debugger pages; Quest FPS / draw-call / triangle ranges from Meta's "Testing and performance analysis" page (last updated 2024-10-30, still the official document fetched on 2026-11-10).
> **Not verified:** Project Auditor's exact "released for 6000.5" version (the 6000.5 profiling-tools page lists the tool; Package Manager's pin is left to you). Some Profiler module and Memory Profiler UI labels may differ slightly between 1.1.12 and 1.2.0.
## Parts
| # | Note | Covers |
|---|---|---|
| 1 | [[1. Profiler Window and a Repeatable Workflow]] | Development builds, attaching the Profiler, modules, Deep Profile |
| 2 | [[2. CPU Allocations and Incremental GC]] | GC spikes, `ProfilerMarker`, `ProfilerRecorder`, Incremental GC |
| 3 | [[3. Memory Profiler Snapshots]] | Managed vs native, capture/compare, leaks, textures |
| 4 | [[4. Frame Debugger and GPU]] | Draw events, Render Graph, overdraw, batching |
| 5 | [[5. Profile Analyzer and Related Tools]] | Comparing captures, Profiling Core, Project Auditor pointer |
| 6 | [[6. Quest Performance Budgets]] | 72 FPS, draw calls, triangles, OVR Metrics, a checklist |
| 7 | [[7. Profiling Pitfalls]] | Editor-vs-device, Deep Profile overhead, false budgets |
## Design lens (Level Up!)
Rogers' camera, character and combat chapters ([[Level Up! (Review)]], Levels 5-7 and 10) are all about *feel*. Feel dies when the frame rate stutters, when a garbage collection hitch lands in a jump, or when a Quest frame is reprojected. Profiling is how you keep the metrics gym ([[5. Gray-Box Metrics Gym]]) honest on the hardware you actually ship.
## Patterns used (Game Programming Patterns)
- **Object Pool** - the standard answer to `Instantiate`/`Destroy` spikes (see also [[Interactable Audio]] for audio sources).
- **Flyweight** - share mesh/material/data; Terrain details are the textbook case ([[3. Trees Details and the Flyweight]]).
- **Spatial Partition** - don't test every object every frame ([[5. Spatial Hashing Separation and Damage]] in [[DOTS]]).
- **Data Locality** - why DOTS and why a missed cache shows up as CPU time ([[Game Programming Patterns (Review)]]).
## Related (existing)
- [[5.Quest 2 Performance and Rendering]] and [[3.Quest 2 Project and Build Setup]]
- [[7. DOTS Profiling Quest and When Not to Use]], [[6. VFX Graph Performance and Quest]], [[6. Terrain Performance Mobile and Quest]]
- [[7.UI Toolkit Pitfalls and Performance]], [[Lighting and Baking]], [[Particle Systems and Layered Effects]]
- [[Unity Test Framework]] - performance tests belong next to these captures, not instead of them
## Sources
- Profiling tools reference (6000.5): https://docs.unity.com/en-us/engine/6000.5/manual/analysis/performance-profiling-tools
- Frame Debugger: https://docs.unity.com/en-us/engine/6000.5/manual/analysis/graphics-performance-profiling/profile-rendering/frame-debugger/debug
- Frame Debugger window reference: https://docs.unity3d.com/6000.5/Documentation/Manual/frame-debugger-window.html
- Memory Profiler 1.1.12 (1.2.0 available): https://docs.unity.com/en-us/engine/6000.5/manual/packages-list/packages-all/pack-safe/com-unity-memoryprofiler
- Profile Analyzer 1.4.2: https://docs.unity.com/en-us/engine/6000.5/manual/packages-list/packages-all/pack-safe/com-unity-performance-profile-analyzer
- Profiling Core 1.0.3: https://docs.unity.com/en-us/engine/6000.5/manual/packages-list/packages-all/pack-safe/com-unity-profiling-core
- Meta Quest testing and performance analysis: https://developers.meta.com/horizon/documentation/unity/unity-perf/
- Quest Performance VRC 1 (linked from that page): https://developers.meta.com/resources/vrc-quest-performance-1/
See also (added 2026-11-10): [[Custom URP Renderer Features]] - use the Render Graph Viewer and Frame Debugger on a custom pass; every extra full-screen blit is a Quest budget item.