---
title: "NSAllocateMemoryPages(_:)"
framework: foundation
role: symbol
role_heading: Function
path: "foundation/nsallocatememorypages(_:)"
---

# NSAllocateMemoryPages(_:)

Allocates a new block of memory.

## Declaration

```swift
func NSAllocateMemoryPages(_ bytes: Int) -> UnsafeMutableRawPointer
```

## Discussion

Discussion Allocates the integral number of pages whose total size is closest to, but not less than, byteCount. The allocated pages are guaranteed to be filled with zeros. If the allocation fails, raises NSInvalidArgumentException.

## See Also

### Memory Management

- [NSCopyMemoryPages(_:_:_:)](foundation/nscopymemorypages(_:_:_:).md)
- [NSDeallocateMemoryPages(_:_:)](foundation/nsdeallocatememorypages(_:_:).md)
- [NSLogPageSize()](foundation/nslogpagesize().md)
- [NSPageSize()](foundation/nspagesize().md)
- [NSRealMemoryAvailable()](foundation/nsrealmemoryavailable().md)
- [NSRoundDownToMultipleOfPageSize(_:)](foundation/nsrounddowntomultipleofpagesize(_:).md)
- [NSRoundUpToMultipleOfPageSize(_:)](foundation/nsrounduptomultipleofpagesize(_:).md)
