<!--
{
  "availability" : [
    "iOS: 5.0.0 -",
    "iPadOS: 5.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.7.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "XPC",
  "identifier" : "/documentation/XPC/xpc_retain",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "XPC"
    ],
    "preciseIdentifier" : "c:@F@xpc_retain"
  },
  "title" : "xpc_retain"
}
-->

# xpc_retain

Increments the reference count of an object.

```
extern xpc_object_txpc_retain(xpc_object_t object);
```

## Parameters

`object`

The object which is to be manipulated.

## Return Value

The object which was given.

## Discussion

Calls to [`xpc_retain`](/documentation/XPC/xpc_retain) must be balanced with calls to [`xpc_release`](/documentation/XPC/xpc_release) to avoid leaking memory.

---

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)