FROM : Christopher Nebel
DATE : Thu Feb 07 18:50:38 2008
On Feb 6, 2008, at 5:23 PM, Ben Trumbull wrote:
> objc_assign_strongCast() will issue a write barrier, informing GC
> that the destination value has changed. But if the only references
> to this pointer are in unscanned (not GC) memory, than the GC system
> will think it's dead as no references to that pointer exist in
> scanned (GC live) memory.
>
> The C++ new operator allocates from malloc(), just as before.
> malloc() memory is not GC scanned. It's probably easiest to instead
> use CFRetain and balance it with CFRelease in delete/etc.
You could also define a custom "new" operator for the class in
question that allocates its memory using NSAllocateCollectable(...,
NSScannedOption), but that might be more trouble than it's worth.
--Chris N.
DATE : Thu Feb 07 18:50:38 2008
On Feb 6, 2008, at 5:23 PM, Ben Trumbull wrote:
> objc_assign_strongCast() will issue a write barrier, informing GC
> that the destination value has changed. But if the only references
> to this pointer are in unscanned (not GC) memory, than the GC system
> will think it's dead as no references to that pointer exist in
> scanned (GC live) memory.
>
> The C++ new operator allocates from malloc(), just as before.
> malloc() memory is not GC scanned. It's probably easiest to instead
> use CFRetain and balance it with CFRelease in delete/etc.
You could also define a custom "new" operator for the class in
question that allocates its memory using NSAllocateCollectable(...,
NSScannedOption), but that might be more trouble than it's worth.
--Chris N.
| Related mails | Author | Date |
|---|---|---|
| David Elliott | Feb 7, 00:27 | |
| Ben Trumbull | Feb 7, 02:23 | |
| David Elliott | Feb 7, 08:50 | |
| Christopher Nebel | Feb 7, 18:50 | |
| David Elliott | Feb 7, 21:07 | |
| Ben Trumbull | Feb 8, 10:01 |






Cocoa mail archive

