# Start()

> Start data collection.

## Definition

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

```csharp
public void Start()
```

### Remarks

Newly constructed recorder is not collecting samples unless [ProfilerRecorderOptions.StartImmediately](/engine/6000.0/script-reference/unity/profiling/profilerrecorderoptions/startimmediately.md) option is specified. Use Start to attach ProfilerRecorder to the Profiler metric and start data collection.

**Note:** Starting recorder which has 0 [ProfilerRecorder.Capacity](/engine/6000.0/script-reference/unity/profiling/profilerrecorder/capacity.md) throws InvalidOperationException.

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

public class ExampleScript : MonoBehaviour
{
    ProfilerRecorder mainThreadTimeRecorder;

    void OnEnable()
    {
        mainThreadTimeRecorder = new ProfilerRecorder(ProfilerCategory.Internal, "Main Thread", 15);
        mainThreadTimeRecorder.Start();
    }

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

When you don't need data to be collected use [ProfilerRecorder.Stop](/engine/6000.0/script-reference/unity/profiling/profilerrecorder/stop.md) to detach recorder from counter or marker. And [ProfilerRecorder.Dispose](/engine/6000.0/script-reference/unity/profiling/profilerrecorder/dispose.md) to free unmanaged resources.
