# GetSampleMetadataAsLong(int, int)

> Gets sample metadata value as long.

## Definition

* **Type:** Method
* **Namespace:** [UnityEditor.Profiling](/engine/6000.6/script-reference/unityeditor/profiling.md)
* **Assembly:** UnityEditor.CoreModule

```csharp
public long GetSampleMetadataAsLong(int sampleIndex, int metadataIndex)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Index of the Profiler sample.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Metadata index.

### Returns

| Type                                                        | Description                                           |
| ----------------------------------------------------------- | ----------------------------------------------------- |
| [long](https://learn.microsoft.com/dotnet/api/system.int64) | Returns long representation of sample metadata value. |

### Remarks

Use to obtain additional data associated with the sample. *metadataIndex* must be between 0 and [RawFrameDataView.GetSampleMetadataCount](/engine/6000.6/script-reference/unityeditor/profiling/rawframedataview/getsamplemetadatacount.md).

### Examples

```csharp
using System;
using Unity.Collections;
using UnityEditor.Profiling;
using UnityEditorInternal;
using UnityEngine;
using UnityEngine.Profiling;

public class Example
{
    public static long GetGCAllocs(int frameIndex)
    {
        long totalGcAllocSize = 0;

        int gcAllocMarkerId = FrameDataView.invalidMarkerId;

        for (int threadIndex = 0;; ++threadIndex)
        {
            using (RawFrameDataView frameData = ProfilerDriver.GetRawFrameDataView(frameIndex, threadIndex))
            {
                if (!frameData.valid)
                    break;

                if (gcAllocMarkerId == FrameDataView.invalidMarkerId)
                {
                    gcAllocMarkerId = frameData.GetMarkerId("GC.Alloc");
                    if (gcAllocMarkerId == FrameDataView.invalidMarkerId)
                        break;
                }

                int sampleCount = frameData.sampleCount;
                for (int i = 0; i < sampleCount; ++i)
                {
                    if (gcAllocMarkerId != frameData.GetSampleMarkerId(i))
                        continue;

                    long gcAllocSize = frameData.GetSampleMetadataAsLong(i, 0);
                    totalGcAllocSize += gcAllocSize;
                }
            }
        }

        return totalGcAllocSize;
    }
}
```
