---
title: "makeBuffer(bytesNoCopy:length:options:deallocator:)"
framework: metal
role: symbol
role_heading: Instance Method
path: "metal/mtldevice/makebuffer(bytesnocopy:length:options:deallocator:)"
---

# makeBuffer(bytesNoCopy:length:options:deallocator:)

Creates a buffer that wraps an existing contiguous memory allocation.

## Declaration

```swift
func makeBuffer(bytesNoCopy pointer: UnsafeMutableRawPointer, length: Int, options: MTLResourceOptions = [], deallocator: (@Sendable (UnsafeMutableRawPointer, Int) -> Void)? = nil) -> (any MTLBuffer)?
```

## Parameters

- `pointer`: A page-aligned pointer to the starting memory address.
- `length`: The size of the new buffer, in bytes, that results in a page-aligned region of memory.
- `options`: An doc://com.apple.metal/documentation/Metal/MTLResourceOptions instance that sets the buffer’s storage and hazard-tracking modes. See doc://com.apple.metal/documentation/Metal/resource-fundamentals and doc://com.apple.metal/documentation/Metal/setting-resource-storage-modes for more information.
- `deallocator`: A block the framework invokes when it deallocates the buffer so that your app can release the underlying memory; otherwise nil to opt out.

## Return Value

Return Value A new MTLBuffer instance if the method completes successfully; otherwise nil.

## Discussion

Discussion important: The existing memory allocation needs to exist within a single virtual memory (VM) region.

## See Also

### Creating buffers

- [maxBufferLength](metal/mtldevice/maxbufferlength.md)
- [makeBuffer(length:options:)](metal/mtldevice/makebuffer(length:options:).md)
- [makeBuffer(bytes:length:options:)](metal/mtldevice/makebuffer(bytes:length:options:).md)
