# Profiler

> Controls the Profiler from script.

## Definition

* **Type:** Class
* **Namespace:** [UnityEngine.Profiling](/engine/6000.6/script-reference/unityengine/profiling.md)
* **Assembly:** UnityEngine.CoreModule

```csharp
public sealed class Profiler
```

## Remarks

You can add custom Profiler sections in your scripts with [Profiler.BeginSample](/engine/6000.6/script-reference/unityengine/profiling/profiler/beginsample.md) and [Profiler.EndSample](/engine/6000.6/script-reference/unityengine/profiling/profiler/endsample.md).

On standalone platforms, you can save all profiling information to a file, which allows you to inspect it later. To do this, you must specify a [Profiler.logFile](/engine/6000.6/script-reference/unityengine/profiling/profiler/logfile.md) and set both [Profiler.enabled](/engine/6000.6/script-reference/unityengine/profiling/profiler/enabled.md) and [Profiler.enableBinaryLog](/engine/6000.6/script-reference/unityengine/profiling/profiler/enablebinarylog.md) to `true`.

Because use of the Profiler negatively affects the performance of your application, most of the Profiler API functionality is only available when you enable the **Development Build** option or set the [ManagedCodeVariant](/engine/6000.6/script-reference/unityeditor/managedcodevariant.md) to one that defines the `ENABLE_PROFILER` scripting symbol. Disabling **Development Build** makes your application run faster, but prevents you from using most of the Profiler API methods.

The exception to this are the Profiler API methods relating to memory usage, which are available even if you don't enable **Development Build** or select a [ManagedCodeVariant](/engine/6000.6/script-reference/unityeditor/managedcodevariant.md) that doesn't define the `ENABLE_PROFILER` scripting symbol. This is because Unity manages most of its system memory at runtime, which means it can provide that information with no impact on performance. This applies to all memory-related Profiler API methods except [Profiler.GetAllocatedMemoryForGraphicsDriver](/engine/6000.6/script-reference/unityengine/profiling/profiler/getallocatedmemoryforgraphicsdriver.md) and [Profiler.GetRuntimeMemorySizeLong](/engine/6000.6/script-reference/unityengine/profiling/profiler/getruntimememorysizelong.md), because they require extra profiling data only available in development builds.

## Static Properties

| Property                                                                                                                   | Description                                                                                                                   |
| -------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| [areaCount](/engine/6000.6/script-reference/unityengine/profiling/profiler/areacount.md)                                   | The number of [Profiler Areas](/engine/6000.6/script-reference/unityengine/profiling/profilerarea.md) that you can profile.   |
| [enableAllocationCallstacks](/engine/6000.6/script-reference/unityengine/profiling/profiler/enableallocationcallstacks.md) | Enables the recording of callstacks for managed allocations.                                                                  |
| [enableBinaryLog](/engine/6000.6/script-reference/unityengine/profiling/profiler/enablebinarylog.md)                       | Enables the logging of profiling data to a file.                                                                              |
| [enabled](/engine/6000.6/script-reference/unityengine/profiling/profiler/enabled.md)                                       | Enables the Profiler.                                                                                                         |
| [logFile](/engine/6000.6/script-reference/unityengine/profiling/profiler/logfile.md)                                       | Specifies the file to use when writing profiling data.                                                                        |
| [maxUsedMemory](/engine/6000.6/script-reference/unityengine/profiling/profiler/maxusedmemory.md)                           | Sets the maximum amount of memory that Profiler uses for buffering data. This property is expressed in bytes.                 |
| [usedHeapSizeLong](/engine/6000.6/script-reference/unityengine/profiling/profiler/usedheapsizelong.md)                     | Returns the number of bytes that Unity has allocated. This does not include bytes allocated by external libraries or drivers. |

## Static Methods

| Method                                                                                                                                       | Description                                                                                                                                                                                                                                                                                                     |
| -------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [AddFramesFromFile](/engine/6000.6/script-reference/unityengine/profiling/profiler/addframesfromfile.md)                                     | Displays the recorded profile data in the profiler.                                                                                                                                                                                                                                                             |
| [BeginSample](/engine/6000.6/script-reference/unityengine/profiling/profiler/beginsample.md)                                                 | Begin profiling a piece of code with a custom label.                                                                                                                                                                                                                                                            |
| [BeginThreadProfiling](/engine/6000.6/script-reference/unityengine/profiling/profiler/beginthreadprofiling.md)                               | Enables profiling on the thread from which you call this method.                                                                                                                                                                                                                                                |
| [EmitFrameMetaData](/engine/6000.6/script-reference/unityengine/profiling/profiler/emitframemetadata.md)                                     | Write metadata associated with the current frame to the Profiler stream.                                                                                                                                                                                                                                        |
| [EmitSessionMetaData](/engine/6000.6/script-reference/unityengine/profiling/profiler/emitsessionmetadata.md)                                 | Write metadata associated with the whole Profiler session capture.                                                                                                                                                                                                                                              |
| [EndSample](/engine/6000.6/script-reference/unityengine/profiling/profiler/endsample.md)                                                     | Ends the current profiling sample.                                                                                                                                                                                                                                                                              |
| [EndThreadProfiling](/engine/6000.6/script-reference/unityengine/profiling/profiler/endthreadprofiling.md)                                   | Frees the internal resources used by the Profiler for the thread.                                                                                                                                                                                                                                               |
| [GetAllCategories](/engine/6000.6/script-reference/unityengine/profiling/profiler/getallcategories.md)                                       | Returns all [ProfilerCategory](/engine/6000.6/script-reference/unity/profiling/profilercategory.md) registered in Profiler.                                                                                                                                                                                     |
| [GetAllocatedMemoryForGraphicsDriver](/engine/6000.6/script-reference/unityengine/profiling/profiler/getallocatedmemoryforgraphicsdriver.md) | Returns the estimated amount of allocated memory for the graphics driver, in bytes.                                                                                                                                                                                                                             |
| [GetAreaEnabled](/engine/6000.6/script-reference/unityengine/profiling/profiler/getareaenabled.md)                                           | Returns whether or not a given [ProfilerArea](/engine/6000.6/script-reference/unityengine/profiling/profilerarea.md) is currently enabled.                                                                                                                                                                      |
| [GetCategoriesCount](/engine/6000.6/script-reference/unityengine/profiling/profiler/getcategoriescount.md)                                   | Returns number of [ProfilerCategory](/engine/6000.6/script-reference/unity/profiling/profilercategory.md) registered in Profiler.                                                                                                                                                                               |
| [GetMonoHeapSizeLong](/engine/6000.6/script-reference/unityengine/profiling/profiler/getmonoheapsizelong.md)                                 | Returns the size of the reserved space for managed-memory.                                                                                                                                                                                                                                                      |
| [GetMonoUsedSizeLong](/engine/6000.6/script-reference/unityengine/profiling/profiler/getmonousedsizelong.md)                                 | Gets the allocated managed memory for live objects and non-collected objects.                                                                                                                                                                                                                                   |
| [GetRuntimeMemorySizeLong](/engine/6000.6/script-reference/unityengine/profiling/profiler/getruntimememorysizelong.md)                       | Gathers the native-memory used by a Unity object.                                                                                                                                                                                                                                                               |
| [GetTempAllocatorSize](/engine/6000.6/script-reference/unityengine/profiling/profiler/gettempallocatorsize.md)                               | Returns the size of the temp allocator.                                                                                                                                                                                                                                                                         |
| [GetTotalAllocatedMemoryLong](/engine/6000.6/script-reference/unityengine/profiling/profiler/gettotalallocatedmemorylong.md)                 | The total memory allocated by the internal allocators in Unity. Unity reserves large pools of memory from the system; this includes double the required memory for textures because Unity keeps a copy of each texture on both the CPU and GPU. This function returns the amount of used memory in those pools. |
| [GetTotalFragmentationInfo](/engine/6000.6/script-reference/unityengine/profiling/profiler/gettotalfragmentationinfo.md)                     | Returns heap memory fragmentation information.                                                                                                                                                                                                                                                                  |
| [GetTotalReservedMemoryLong](/engine/6000.6/script-reference/unityengine/profiling/profiler/gettotalreservedmemorylong.md)                   | The total memory Unity has reserved.                                                                                                                                                                                                                                                                            |
| [GetTotalUnusedReservedMemoryLong](/engine/6000.6/script-reference/unityengine/profiling/profiler/gettotalunusedreservedmemorylong.md)       | Unity allocates memory in pools for usage when unity needs to allocate memory. This function returns the amount of unused memory in these pools.                                                                                                                                                                |
| [IsCategoryEnabled](/engine/6000.6/script-reference/unityengine/profiling/profiler/iscategoryenabled.md)                                     | Returns whether or not a given [ProfilerCategory](/engine/6000.6/script-reference/unity/profiling/profilercategory.md) is currently enabled.                                                                                                                                                                    |
| [SetAreaEnabled](/engine/6000.6/script-reference/unityengine/profiling/profiler/setareaenabled.md)                                           | Enable or disable a given [ProfilerArea](/engine/6000.6/script-reference/unityengine/profiling/profilerarea.md).                                                                                                                                                                                                |
| [SetCategoryEnabled](/engine/6000.6/script-reference/unityengine/profiling/profiler/setcategoryenabled.md)                                   | Enable or disable a given [ProfilerCategory](/engine/6000.6/script-reference/unity/profiling/profilercategory.md).                                                                                                                                                                                              |
| [SetScreenshotCaptureFrameInterval](/engine/6000.6/script-reference/unityengine/profiling/profiler/setscreenshotcaptureframeinterval.md)     | Alter the rate that the Profiler takes a new screenshot for capture list thumbnails.                                                                                                                                                                                                                            |
| [SetTempAllocatorRequestedSize](/engine/6000.6/script-reference/unityengine/profiling/profiler/settempallocatorrequestedsize.md)             | Sets the size of the temp allocator.                                                                                                                                                                                                                                                                            |
