# CollectOnlyOnCurrentThread

> Use to collect samples only on the thread ProfilerRecorder was initialized on.

## Definition

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

```csharp
CollectOnlyOnCurrentThread = 4
```

### Examples

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

public class CollectGCAllocCountExample
{
    static void PrintGCAllocCount(Action a)
    {
        using (var gcAllocRecorder = ProfilerRecorder.StartNew(ProfilerCategory.Internal, "GC.Alloc", 100, ProfilerRecorderOptions.CollectOnlyOnCurrentThread))
        {
            a.Invoke();

            gcAllocRecorder.Stop();

            Debug.Log("GC allocs count: " + gcAllocRecorder.Count);
        }
    }
}
```
