---
title: Manual Memory Management
framework: swift
role: collectionGroup
role_heading: API Collection
path: swift/manual-memory-management
---

# Manual Memory Management

Allocate and manage memory manually.

## Topics

### First Steps

- [Calling Functions With Pointer Parameters](swift/calling-functions-with-pointer-parameters.md)

### Safe Memory Access

- [Span](swift/span.md)
- [RawSpan](swift/rawspan.md)
- [OutputSpan](swift/outputspan.md)
- [OutputRawSpan](swift/outputrawspan.md)
- [UTF8Span](swift/utf8span.md)
- [MutableSpan](swift/mutablespan.md)
- [MutableRawSpan](swift/mutablerawspan.md)

### Typed Pointers

- [UnsafePointer](swift/unsafepointer.md)
- [UnsafeMutablePointer](swift/unsafemutablepointer.md)
- [UnsafeBufferPointer](swift/unsafebufferpointer.md)
- [UnsafeMutableBufferPointer](swift/unsafemutablebufferpointer.md)

### Raw Pointers

- [UnsafeRawPointer](swift/unsaferawpointer.md)
- [UnsafeMutableRawPointer](swift/unsafemutablerawpointer.md)
- [UnsafeRawBufferPointer](swift/unsaferawbufferpointer.md)
- [UnsafeMutableRawBufferPointer](swift/unsafemutablerawbufferpointer.md)

### Memory Access

- [withUnsafePointer(to:_:)](swift/withunsafepointer(to:_:)-9fjn6.md)
- [withUnsafePointer(to:_:)](swift/withunsafepointer(to:_:)-35wrn.md)
- [withUnsafeMutablePointer(to:_:)](swift/withunsafemutablepointer(to:_:).md)
- [withUnsafeBytes(of:_:)](swift/withunsafebytes(of:_:)-5zxtl.md)
- [withUnsafeBytes(of:_:)](swift/withunsafebytes(of:_:)-5gesg.md)
- [withUnsafeMutableBytes(of:_:)](swift/withunsafemutablebytes(of:_:).md)
- [withUnsafeTemporaryAllocation(of:capacity:_:)](swift/withunsafetemporaryallocation(of:capacity:_:).md)
- [withUnsafeTemporaryAllocation(byteCount:alignment:_:)](swift/withunsafetemporaryallocation(bytecount:alignment:_:).md)
- [swap(_:_:)](swift/swap(_:_:).md)
- [exchange(_:with:)](swift/exchange(_:with:).md)

### Memory Layout

- [MemoryLayout](swift/memorylayout.md)

### Reference Counting

- [Unmanaged](swift/unmanaged.md)
- [withExtendedLifetime(_:_:)](swift/withextendedlifetime(_:_:)-4mmpv.md)
- [withExtendedLifetime(_:_:)](swift/withextendedlifetime(_:_:)-59dz3.md)
- [extendLifetime(_:)](swift/extendlifetime(_:).md)

## See Also

### Programming Tasks

- [Input and Output](swift/input-and-output.md)
- [Debugging and Reflection](swift/debugging-and-reflection.md)
- [Macros](swift/macros.md)
- [Concurrency](swift/concurrency.md)
- [Key-Path Expressions](swift/key-path-expressions.md)
- [Type Casting and Existential Types](swift/type-casting-and-existential-types.md)
- [C Interoperability](swift/c-interoperability.md)
- [Operator Declarations](swift/operator-declarations.md)
