---
title: Record and view call stacks for Profiler samples
product: Unity Editor
version: '7000.0'
latest_version: '7000.0'
status: This page documents version 7000.0. The latest version is 7000.0.
canonical: https://docs.unity.com/en-us/engine/7000.0/manual/analysis/profiler/visualizing-data/cpu/call-stacks
latest_url: https://docs.unity.com/en-us/engine/7000.0/manual/analysis/profiler/visualizing-data/cpu/call-stacks.md
last_updated: 2026-11-25
generated_at: 2026-11-27T13:40:00.344Z
locale: en-us
---

# Record and view call stacks for Profiler samples

> Record call stacks for GC.Alloc, UnsafeUtility.Malloc, and JobHandle.Complete samples to find the code that triggers them.

Use the CPU Usage Profiler module to record call stacks for `GC.Alloc`, `UnsafeUtility.Malloc`, and `JobHandle.Complete` samples and find the code that triggers them.

Whenever a script creates a new managed object that doesn't fit in the current memory heap, Unity performs [garbage collection](/engine/7000.0/manual/analysis/performance-memory/managed-memory/garbage-collector.md). Garbage collection pauses all threads and scans the managed heap for unused memory. This process might take a long time and disrupt the frame rate. Managed garbage collection appears as `GC.Collect` samples in the Profiler, while managed allocations appear as `GC.Alloc`.

To prevent the garbage collector from affecting your application's frame rate and to keep the heap size small, try to keep the `GC.Alloc` value at zero while your application runs. In the [Timeline view](/engine/7000.0/manual/analysis/profiler/visualizing-data/cpu/cpu/timeline.md), `GC.Alloc` samples appear colored in red-magenta and represent the size of the allocation.

To learn where in the code managed allocations happen, you can enable the [full call stacks for `GC.Alloc`](#enable-full-call-stacks). For more information about the managed heap, refer to the documentation on [Managed memory](/engine/7000.0/manual/analysis/performance-memory/managed-memory.md).

## Enable full call stacks

You can enable full call stacks for samples that `GC.Alloc`, `UnsafeUtility.Malloc`, and `JobHandle.Complete` emit. To enable these call stacks:

1. In the Profiler window toolbar, enable **Call Stacks**. By default, this enables the call stacks for `GC.Alloc` samples.
2. To enable other call stacks, select the dropdown arrow and enable any of the other markers you want to display the call stacks for.

You can use this functionality whether you profile in the Unity Editor or on a running Player. This only takes effect for the frames you profile after you enable call stacks.

## View call stacks

To investigate call stacks:

1. Select a `GC.Alloc`, `UnsafeUtility.Malloc`, or `JobHandle.Complete` sample.
2. In the [**Timeline** view](/engine/7000.0/manual/analysis/profiler/visualizing-data/cpu/cpu/timeline.md), a `Profiler.Callstack` sample appears nested under the selected sample.
3. Switch to the [**Hierarchy** view](/engine/7000.0/manual/analysis/profiler/visualizing-data/cpu/cpu/hierarchy.md) and set the **Details** dropdown to **Related Data** to view the full details of the call stack.

> **Note:**
>
> In the [**Old Timeline (Legacy)** view](/engine/7000.0/manual/analysis/profiler/visualizing-data/cpu/cpu/timeline.md#old-timeline-legacy), you can hover over a sample and select **Copy** to copy details of the call stack.

## Additional resources

* [Connecting the Profiler to a data source](/engine/7000.0/manual/analysis/profiler/profiling-applications.md)
* [CPU Usage Profiler module reference](/engine/7000.0/manual/analysis/profiler/visualizing-data/cpu/cpu.md)
* [Use AI Assistant to analyze profiler data from Unity Profiler](https://docs.unity3d.com/Packages/com.unity.ai.assistant@latest?subfolder=/manual/assistant-profiler-integration.html)
* [Profiler markers](/engine/7000.0/manual/analysis/profiler/markers.md)
