---
title: "allocate(byteCount:alignment:)"
framework: swift
role: symbol
role_heading: Type Method
path: "swift/unsafemutablerawbufferpointer/allocate(bytecount:alignment:)"
---

# allocate(byteCount:alignment:)

Allocates uninitialized memory with the specified size and alignment.

## Declaration

```swift
static func allocate(byteCount: Int, alignment: Int) -> UnsafeMutableRawBufferPointer
```

## Parameters

- `byteCount`: The number of bytes to allocate. byteCount must not be negative.
- `alignment`: The alignment of the new region of allocated memory, in bytes. alignment must be a whole power of 2.

## Return Value

Return Value A buffer pointer to a newly allocated region of memory aligned to alignment.

## Discussion

Discussion You are in charge of managing the allocated memory. Be sure to deallocate any memory that you manually allocate. The allocated memory is not bound to any specific type and must be bound before performing any typed operations. If you are using the memory for a specific type, allocate memory using the UnsafeMutablePointerBuffer.allocate(capacity:) static method instead.
