# CreateBuffer(ulong, ulong)

> Allocates a new buffer on the device with the specified element count and stride.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine.LightTransport](/engine/6000.5/script-reference/unityengine/lighttransport.md)
* **Assembly:** UnityEngine.CoreModule

```csharp
BufferID CreateBuffer(ulong count, ulong stride)
```

### Parameters

**** (\[ulong]\(https\://learn.microsoft.com/dotnet/api/system.uint64)): Number of elements in the buffer.**** (\[ulong]\(https\://learn.microsoft.com/dotnet/api/system.uint64)): Size of each element in bytes.

### Returns

| Type                                                                               | Description                                     |
| ---------------------------------------------------------------------------------- | ----------------------------------------------- |
| [BufferID](/engine/6000.5/script-reference/unityengine/lighttransport/bufferid.md) | Unique identifier for the newly created buffer. |

### Remarks

Creates a buffer that can store the specified number of elements, each with the given stride (size in bytes). The actual memory allocation may occur in CPU memory, GPU memory, or unified memory depending on the hardware platform and implementation.

The returned [BufferID](/engine/6000.5/script-reference/unityengine/lighttransport/bufferid.md) can be used to create typed [BufferSlice](/engine/6000.5/script-reference/unityengine/lighttransport/bufferslice1.md) objects for reading and writing data.

**Note:** Buffers must be destroyed using [IDeviceContext.DestroyBuffer](/engine/6000.5/script-reference/unityengine/lighttransport/idevicecontext/destroybuffer.md) to avoid memory leaks.

### Examples

```csharp
// Create a buffer for 1000 integers
BufferID bufferId = context.CreateBuffer(1000, sizeof(int));
var intSlice = new BufferSlice<int>(bufferId, 0);

// Create a buffer for 500 Vector3 structures
BufferID vectorBuffer = context.CreateBuffer(500, 12); // size is 3 floats * 4 bytes
var vectorSlice = new BufferSlice<Vector3>(vectorBuffer, 0);
```
