Skip navigation.
 
mlRe: A coding pattern that does not work under Garbage Collection
FROM : Rick Hoge
DATE : Fri Nov 09 17:47:31 2007

[...]

>> You kept a (default, no strong or weak modifier) pointer to data 
>> inside the object, but no one kept a pointer to the object, so it 
>> was collected.


So if I had added the __strong modifier to the pointer assignment, the 
collector would know not that the memory was still in use?

>> As there are probably better ways of approaching this kind of 
>> situation, I'd be interested in any suggestions or comments.  The 
>> way I was doing it before was probably just bad...

>
> You can allocate GC'd memory with NSAllocateCollectable.


Thanks - this is very helpful.  I am trying to find code examples but 
the usage is fairly clear.  Playing with this in Instruments it looks 
like it does what it's supposed to.

Rick