# StartNew

> Initialize a new instance of ProfilerRecorder and start data collection.

## Definition

* **Type:** Method
* **Namespace:** [Unity.Profiling](/engine/6000.7/script-reference/unity/profiling.md)
* **Assembly:** UnityEngine.CoreModule

## StartNew(ProfilerCategory, string, int, ProfilerRecorderOptions)

Initialize a new instance of ProfilerRecorder and start data collection.

```csharp
public static ProfilerRecorder StartNew(ProfilerCategory category, string statName, int capacity = 1, ProfilerRecorderOptions options = ProfilerRecorderOptions.Default)
```

### Parameters

**** (\[ProfilerCategory]\(/engine/6000.7/script-reference/unity/profiling/profilercategory)): Profiler category.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Profiler marker or counter name.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Maximum amount of samples to be collect. Must be greater than 0.**** (\[ProfilerRecorderOptions]\(/engine/6000.7/script-reference/unity/profiling/profilerrecorderoptions)): ProfilerRecorder options.

### Returns

| Type                                                                                    | Description                            |
| --------------------------------------------------------------------------------------- | -------------------------------------- |
| [ProfilerRecorder](/engine/6000.7/script-reference/unity/profiling/profilerrecorder.md) | Returns new enabled recorder instance. |

### Remarks

For a list of built-in Profiler markers available, see the User Manual documentation on [Common Profiler markers](/engine/6000.7/manual/analysis/profiler/markers.md).

**Note:** *capacity* paramether must be greater than 0, otherwise StartNew throws an exception.

```csharp
using Unity.Profiling;
using UnityEngine;

public class ExampleScript : MonoBehaviour
{
    ProfilerRecorder systemMemoryRecorder;
    ProfilerRecorder gcMemoryRecorder;
    ProfilerRecorder mainThreadTimeRecorder;

    void OnEnable()
    {
        systemMemoryRecorder = ProfilerRecorder.StartNew(ProfilerCategory.Memory, "System Used Memory");
        gcMemoryRecorder = ProfilerRecorder.StartNew(ProfilerCategory.Memory, "GC Reserved Memory");
        mainThreadTimeRecorder = ProfilerRecorder.StartNew(ProfilerCategory.Internal, "Main Thread", 15);
    }

    void OnDisable()
    {
        systemMemoryRecorder.Dispose();
        gcMemoryRecorder.Dispose();
        mainThreadTimeRecorder.Dispose();
    }
}
```

Additional Resources: ctor.

## StartNew(ProfilerMarker, int, ProfilerRecorderOptions)

Initialize a new instance of ProfilerRecorder for ProfilerMarker and start data collection.

```csharp
public static ProfilerRecorder StartNew(ProfilerMarker marker, int capacity = 1, ProfilerRecorderOptions options = ProfilerRecorderOptions.Default)
```

### Parameters

**** (\[ProfilerMarker]\(/engine/6000.7/script-reference/unity/profiling/profilermarker)): Profiler marker instance.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Maximum amount of samples to be collected. Must be greater than 0.**** (\[ProfilerRecorderOptions]\(/engine/6000.7/script-reference/unity/profiling/profilerrecorderoptions)): Profiler recorder options.

### Returns

| Type                                                                                    | Description                            |
| --------------------------------------------------------------------------------------- | -------------------------------------- |
| [ProfilerRecorder](/engine/6000.7/script-reference/unity/profiling/profilerrecorder.md) | Returns new enabled recorder instance. |

### Remarks

Additional Resources:: [ProfilerMarker](/engine/6000.7/script-reference/unity/profiling/profilermarker.md).
