---
title: "xpc_shmem_create(_:_:)"
framework: xpc
role: symbol
role_heading: Function
path: "xpc/xpc_shmem_create(_:_:)"
---

# xpc_shmem_create(_:_:)

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

## Declaration

```swift
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

Return Value A new shared memory object.

## Discussion

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.

## See Also

### Shared memory objects

- [xpc_shmem_map(_:_:)](xpc/xpc_shmem_map(_:_:).md)
