Download Garbage Collection Programming Guide (Retired
Transcript
Using Garbage Collection Compiler Flag // use the data from newData... } This ensures that myData remains on the stack until after you have finished processing the data it contains. Compiler Flag You can use the -Wassign-intercept compiler flag to find out when write-barriers are being used in your code. When you set the flag, the compiler logs a message when it offloads an assignment statement to a helper function. Typically you use the flag to find situations where a write-barrier is not actually used. A missing write-barrier can cause various problems—primarily when memory is being collected before you expect it to be. This is of particular interest when you’re using pointers to garbage-collected memory—especially pointers to pointers—such as where a left-hand-side cast discards the strong knowledge, as illustrated in the following example: __strong CFDictionaryRef x; // struct or ivar declaration *(CFMutableDictionaryRef)&x = CFDictionaryCreateMutable(...); Retired Document | 2012-07-23 | Copyright © 2012 Apple Inc. All Rights Reserved. 31