osfmk/man/memory_object_destroy.html
Function - Shut down a memory object.
**kern\_return\_t memory\_object\_destroy**** (memory\_object\_control\_t **memory\_control,** kern\_return\_t **reason** );**
memory_control[in memory-cache-control send right] The memory cache control port to be used by the memory manager for cache management requests. This port is provided by the kernel in a memory_object_init call.
reason[in scalar] An error code indicating when the object must be destroyed.
The memory_object_destroy function tells the kernel to shut down the specified memory object. As a result of this call, the kernel no longer supports paging activity or any memory object calls on the memory object. The kernel issues a memory_object_terminate call to pass to the memory manager all rights to the memory object port and the memory control port.
To ensure that any modified cached data is returned before the object is terminated, the memory manager should call memory_object_lock_request with should_flush set and a lock value of VM_PROT_WRITE before it makes the memory_object_destroy call.
The reason code is currently ignored by the kernel.
Only generic errors apply.
Functions: memory_object_lock_request, memory_object_terminate.