<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreFoundation",
  "identifier" : "/documentation/CoreFoundation/CFMachPortInvalidate(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Core Foundation"
    ],
    "preciseIdentifier" : "c:@F@CFMachPortInvalidate"
  },
  "title" : "CFMachPortInvalidate(_:)"
}
-->

# CFMachPortInvalidate(_:)

Invalidates a CFMachPort object, stopping it from receiving any more messages.

```
func CFMachPortInvalidate(_ port: CFMachPort!)
```

## Parameters

`port`

The CFMachPort object to invalidate.

## Discussion

Invalidating a CFMachPort object prevents the port from ever receiving any more messages. The CFMachPort object is not deallocated, though. If the port has not already been invalidated, the port’s invalidation callback function is invoked, if one has been set with [`CFMachPortSetInvalidationCallBack(_:_:)`](/documentation/CoreFoundation/CFMachPortSetInvalidationCallBack(_:_:)). The [`CFMachPortContext`](/documentation/CoreFoundation/CFMachPortContext)  `info` information for `port` is also released, if a release callback was specified in the port’s context structure. Finally, if a run loop source was created for `port`, the run loop source is invalidated, as well.

If the underlying Mach port is destroyed, the CFMachPort object is automatically invalidated.

---

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)