Instance Method

makeAliasable

Allows future heap resource allocations to alias against the resource’s memory.

Required.

Declaration

- (void)makeAliasable;

Discussion

Call this method only if the resource was allocated from a heap.

Making a resource aliasable doesn’t destroy it. The resource can still be used, but future heap suballocations may also refer to the same memory allocation. Once you make a resource aliasable, you can’t revert the action or remap the resource’s memory to a different location. You must use fences or events to avoid accessing this resource at the same time as any resources created after you make this call (because they may share the same memory).

Use aliased resources when you can divide a complex task into multiple stages where each stage has resources that hold transient data for that stage. Aliasing allows you to allocate all of your resources once, and reuse the same memory to hold different data at different stages of the larger task. Allocate a heap to hold all of the resources for the task. Suballocate all the resources needed for the first stage, then mark any resources whose contents aren’t needed in the next stage as aliasable. Repeat that process for each stage. When you encode commands to perform the task, ensure that commands in one stage complete before starting work on the next stage.

See Also

Managing Heap Resources

heapOffset

The distance, in bytes, from the beginning of the heap to the first byte of the resource, if you allocated the resource on a heap.

Required.

heap

The heap on which the resource is allocated, if any.

Required.

- isAliasable

A Boolean value that indicates whether future heap resource allocations may alias against the resource’s memory.

Required.