<!--
{
  "documentType" : "article",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/memory-management-functions",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "Memory Management Functions"
}
-->

# Memory Management Functions

Perform low-level memory management tasks.

## Topics

### Core Foundation ARC Integration

[`func CFBridgingRetain(Any?) -> CFTypeRef?`](/documentation/Foundation/CFBridgingRetain(_:))

Casts an Objective-C pointer to a Core Foundation pointer and also transfers ownership to the caller.

[`static idCFBridgingRelease(CFTypeRef X);`](/documentation/Foundation/CFBridgingRelease)

Moves a non-Objective-C pointer to Objective-C and also transfers ownership to ARC.

### Memory Management

[`func NSAllocateMemoryPages(Int) -> UnsafeMutableRawPointer`](/documentation/Foundation/NSAllocateMemoryPages(_:))

Allocates a new block of memory.

[`func NSCopyMemoryPages(UnsafeRawPointer, UnsafeMutableRawPointer, Int)`](/documentation/Foundation/NSCopyMemoryPages(_:_:_:))

Copies a block of memory.

[`func NSDeallocateMemoryPages(UnsafeMutableRawPointer, Int)`](/documentation/Foundation/NSDeallocateMemoryPages(_:_:))

Deallocates the specified block of memory.

[`func NSLogPageSize() -> Int`](/documentation/Foundation/NSLogPageSize())

Returns the binary log of the page size.

[`func NSPageSize() -> Int`](/documentation/Foundation/NSPageSize())

Returns the number of bytes in a page.

[`func NSRealMemoryAvailable() -> Int`](/documentation/Foundation/NSRealMemoryAvailable())

Returns information about the user’s system.

[`func NSRoundDownToMultipleOfPageSize(Int) -> Int`](/documentation/Foundation/NSRoundDownToMultipleOfPageSize(_:))

Returns the specified number of bytes rounded down to a multiple of the page size.

[`func NSRoundUpToMultipleOfPageSize(Int) -> Int`](/documentation/Foundation/NSRoundUpToMultipleOfPageSize(_:))

Returns the specified number of bytes rounded up to a multiple of the page size.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)