Profiler Optimization

Download

Unity Cheat Sheet: #28

Abhishek Smith

Abhishek Smith

Building Outscal | Land Jobs in the gaming industry | EA, Epic Games, TCS, | CMU, IIT K

Unity Profiler is your detective tool for finding performance issues. Here's what you actually need to know:

Basic Memory Detection

  • GetTotalAllocatedMemory: Shows you TOTAL memory your game is using
  • GetMonoHeapSize: Shows memory used by scripts and game objects
  • GetMonoUsedSize: Shows ACTIVE memory being used right now

Tracking Specific Areas

  • BeginSample("Physics")/EndSample: Like starting/stopping a stopwatch to measure how long your physics calculations take
  • SetAreaEnabled(ProfilerArea.CPU): Turn on CPU tracking to find script bottlenecks
  • SetAreaEnabled(ProfilerArea.GPU): Turn on GPU tracking to find rendering issues
  • SetAreaEnabled(ProfilerArea.Memory): Turn on Memory tracking to find leaks

Frame-by-Frame Analysis

  • CaptureFrameTimings: Takes a snapshot of how long each frame takes
  • GetLatestTimings: Shows you the time data for recent frames
  • CustomSampler.Create: Create custom checkpoints in your code to measure specific functions

Memory Deep Dive

  • TakeSnapshot: Takes a complete picture of memory usage
  • enableBinaryLog: Saves detailed performance data to a file
  • maxUsedMemory: Sets a limit for memory usage during profiling

Common Issues You Can Find:

  • Update() functions taking too long
  • Physics calculations slowing down the game
  • Memory growing without being cleared
  • Specific game features causing frame drops

Show More