---
title: CFAllocator
framework: corefoundation
role: symbol
role_heading: Class
path: corefoundation/cfallocator
---

# CFAllocator

## Declaration

```swift
class CFAllocator
```

## Overview

Overview CFAllocator is an opaque type that allocates and deallocates memory for you. You never have to allocate, reallocate, or deallocate memory directly for Core Foundation objects—and rarely should you. You pass CFAllocator objects into functions that create objects; these functions have “Create” embedded in their names, for example, CFStringCreateWithPascalString. The creation functions use the allocators to allocate memory for the objects they create.

## Topics

### Creating an Allocator

- [CFAllocatorCreate(_:_:)](corefoundation/cfallocatorcreate(_:_:).md)

### Managing Memory with an Allocator

- [CFAllocatorAllocate(_:_:_:)](corefoundation/cfallocatorallocate(_:_:_:).md)
- [CFAllocatorDeallocate(_:_:)](corefoundation/cfallocatordeallocate(_:_:).md)
- [CFAllocatorGetPreferredSizeForSize(_:_:_:)](corefoundation/cfallocatorgetpreferredsizeforsize(_:_:_:).md)
- [CFAllocatorReallocate(_:_:_:_:)](corefoundation/cfallocatorreallocate(_:_:_:_:).md)

### Getting and Setting the Default Allocator

- [CFAllocatorGetDefault()](corefoundation/cfallocatorgetdefault().md)
- [CFAllocatorSetDefault(_:)](corefoundation/cfallocatorsetdefault(_:).md)

### Getting an Allocator’s Context

- [CFAllocatorGetContext(_:_:)](corefoundation/cfallocatorgetcontext(_:_:).md)

### Getting the CFAllocator Type ID

- [CFAllocatorGetTypeID()](corefoundation/cfallocatorgettypeid().md)

### Callbacks

- [CFAllocatorAllocateCallBack](corefoundation/cfallocatorallocatecallback.md)
- [CFAllocatorCopyDescriptionCallBack](corefoundation/cfallocatorcopydescriptioncallback.md)
- [CFAllocatorDeallocateCallBack](corefoundation/cfallocatordeallocatecallback.md)
- [CFAllocatorPreferredSizeCallBack](corefoundation/cfallocatorpreferredsizecallback.md)
- [CFAllocatorReallocateCallBack](corefoundation/cfallocatorreallocatecallback.md)
- [CFAllocatorReleaseCallBack](corefoundation/cfallocatorreleasecallback.md)
- [CFAllocatorRetainCallBack](corefoundation/cfallocatorretaincallback.md)

### Data Types

- [CFAllocatorContext](corefoundation/cfallocatorcontext.md)

### Constants

- [Predefined Allocators](corefoundation/predefined-allocators.md)

## Relationships

### Conforms To

- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)

## See Also

### Related Documentation

- [Memory Management Programming Guide for Core Foundation](apple-archive/documentation/CoreFoundation/Conceptual/CFMemoryMgmt.md)

### Opaque Types

- [CFArray](corefoundation/cfarray.md)
- [CFAttributedString](corefoundation/cfattributedstring.md)
- [CFBag](corefoundation/cfbag.md)
- [CFBinaryHeap](corefoundation/cfbinaryheap.md)
- [CFBitVector](corefoundation/cfbitvector.md)
- [CFBoolean](corefoundation/cfboolean.md)
- [CFBundle](corefoundation/cfbundle.md)
- [CFCalendar](corefoundation/cfcalendar.md)
- [CFCharacterSet](corefoundation/cfcharacterset.md)
- [CFData](corefoundation/cfdata.md)
- [CFDate](corefoundation/cfdate.md)
- [CFDateFormatter](corefoundation/cfdateformatter.md)
- [CFDictionary](corefoundation/cfdictionary.md)
- [CFError](corefoundation/cferror.md)
- [CFFileDescriptor](corefoundation/cffiledescriptor.md)
