---
title: withPersistentMemoryDescriptor
framework: kernel
role: symbol
role_heading: Type Method
path: kernel/iomemorydescriptor/1441983-withpersistentmemorydescriptor
---

# withPersistentMemoryDescriptor

Copy constructor that generates a new memory descriptor if the backing memory for the same task's virtual address and length has changed.

## Declaration

```occ
static OSPtr<IOMemoryDescriptor> withPersistentMemoryDescriptor(IOMemoryDescriptor *originalMD);
```

## Parameters

- `originalMD`: The memory descriptor to be duplicated.

## Return Value

Return Value Either the original memory descriptor with an additional retain or a new memory descriptor, 0 for a bad original memory descriptor or some other resource shortage.

## Discussion

Discussion If the original memory descriptor's address and length is still backed by the same real memory, i.e. the user hasn't deallocated and the reallocated memory at the same address then the original memory descriptor is returned with a additional reference. Otherwise we build a totally new memory descriptor with the same characteristics as the previous one but with a new view of the vm. Note not legal to call this function with anything except an IOGeneralMemoryDescriptor that was created with the kIOMemoryPersistent option.

## See Also

### Creating the Memory Buffer

- [initWithOptions](kernel/iomemorydescriptor/1812826-initwithoptions.md)
- [initWithOptions](kernel/iomemorydescriptor/1441969-initwithoptions.md)
- [withOptions](kernel/iomemorydescriptor/1812897-withoptions.md)
- [withOptions](kernel/iomemorydescriptor/1441825-withoptions.md)
- [withAddress](kernel/iomemorydescriptor/1812881-withaddress.md)
- [withAddress](kernel/iomemorydescriptor/1442032-withaddress.md)
- [withAddressRange](kernel/iomemorydescriptor/1812885-withaddressrange.md)
- [withAddressRange](kernel/iomemorydescriptor/1441897-withaddressrange.md)
- [withAddressRanges](kernel/iomemorydescriptor/1812892-withaddressranges.md)
- [withAddressRanges](kernel/iomemorydescriptor/1441794-withaddressranges.md)
- [withPersistentMemoryDescriptor](kernel/iomemorydescriptor/1812901-withpersistentmemorydescriptor.md)
- [withPhysicalAddress](kernel/iomemorydescriptor/1812908-withphysicaladdress.md)
- [withPhysicalAddress](kernel/iomemorydescriptor/1441877-withphysicaladdress.md)
- [free](driverkit/iomemorydescriptor/free.md)
