Allows future heap resource allocations to alias against the resource’s memory.
- iOS 10.0+
- macOS 10.13+
- Mac Catalyst 13.0+
- tvOS 10.0+
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.