<!--
{
  "availability" : [
    "iOS: 11.0.0 -",
    "iPadOS: 11.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.6.0 -",
    "tvOS: 11.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "IOSurface",
  "identifier" : "/documentation/IOSurface/IOSurfaceCreateMachPort(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "IOSurface"
    ],
    "preciseIdentifier" : "c:@F@IOSurfaceCreateMachPort"
  },
  "title" : "IOSurfaceCreateMachPort(_:)"
}
-->

# IOSurfaceCreateMachPort(_:)

Returns a mach_port_t that holds a reference to the IOSurface.

```
func IOSurfaceCreateMachPort(_ buffer: IOSurfaceRef) -> mach_port_t
```

## Discussion

This is useful if you need to atomically or securely pass an IOSurface to another task without making the surface global to the entire system. The returned port must be deallocated with mach_port_deallocate or the equivalent.

> Note:
> Any live mach ports created from an IOSurfaceRef implicitly increase the IOSurface’s global use count by one until the port is deleted.

---

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)