## memory_object_destroy

Function - Shut down a memory object.

### SYNOPSIS

    kern_return_t   memory_object_destroy
                    (memory_object_control_t         memory_control,
                     kern_return_t                           reason);

### PARAMETERS

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.

### DESCRIPTION

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.

### NOTES

The reason code is currently ignored by the kernel.

### RETURN VALUES

Only generic errors apply.

### RELATED INFORMATION

Functions: memory_object_lock_request, memory_object_terminate.