<!--
{
  "availability" : [
    "macOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Virtualization",
  "identifier" : "/documentation/Virtualization/VZVirtioSharedMemoryRegion/mapMemory(_:atOffset:size:completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Virtualization"
    ],
    "preciseIdentifier" : "c:objc(cs)VZVirtioSharedMemoryRegion(im)mapMemory:atOffset:size:completionHandler:"
  },
  "title" : "mapMemory(_:atOffset:size:completionHandler:)"
}
-->

# mapMemory(_:atOffset:size:completionHandler:)

Maps a chunk of host memory into the shared memory region.

```
func mapMemory(_ memory: UnsafeMutableRawPointer, atOffset offset: UInt64, size: UInt64, completionHandler: @escaping @Sendable ((any Error)?) -> Void)
```

```
func mapMemory(_ memory: UnsafeMutableRawPointer, atOffset offset: UInt64, size: UInt64) async throws
```

## Parameters

`memory`

A pointer to host memory to map into the shared memory region.

`offset`

The offset from the start of the shared memory region where the memory should map to.

`size`

The size of the memory to map into the shared memory region.

`completionHandler`

A block the framework calls after successfully mapping the memory, or on an error.
The error parameter passed to the block is `nil` if the map operation is successful.
The framework invokes the block on [`deviceQueue`](/documentation/Virtualization/VZCustomVirtioDevice/deviceQueue).

---

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)