<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/ManagedBuffer",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:s13ManagedBufferC"
  },
  "title" : "ManagedBuffer"
}
-->

# ManagedBuffer

A class whose instances contain a property of type `Header` and raw
storage for an array of `Element`, whose size is determined at
instance creation.

```
class ManagedBuffer<Header, Element> where Element : ~Copyable
```

## Overview

Note that the `Element` array is suitably-aligned **raw memory**.
You are expected to construct and—if necessary—destroy objects
there yourself, using the APIs on `UnsafeMutablePointer<Element>`.
Typical usage stores a count and capacity in `Header` and destroys
any live elements in the `deinit` of a subclass.

> Note: Subclasses must not have any stored properties; any storage
> needed should be included in `Header`.

---

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)