<!--
{
  "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_shmem_create(_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "XPC"
    ],
    "preciseIdentifier" : "c:@F@xpc_shmem_create"
  },
  "title" : "xpc_shmem_create(_:_:)"
}
-->

# xpc_shmem_create(_:_:)

Creates an XPC object that represents the specified shared memory region.

```
func xpc_shmem_create(_ region: UnsafeMutableRawPointer, _ length: Int) -> xpc_object_t
```

## Parameters

`region`

A pointer to a region of shared memory, created through a call to mmap(2) with the MAP_SHARED flag, which is to be boxed.

`length`

The length of the region.

## Return Value

A new shared memory object.

## Discussion

This API is NOT for making a private region of memory shareable. It is to allow for already-shareable regions of memory to be boxed in an XPC object. Do not pass a region allocated with `malloc(3)` or friends to this API.

---

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)