That makes sense, although 'NSPointerFunctionsStrongMemory| NSPointerFunctionsOpaqueMemory' gives the error:

*** -[NSPointerArray initWithOptions:] Requested configuration not supported.

What I did try was 'NSPointerFunctionsStrongMemory| NSPointerFunctionsObjectPointerPersonality' which does work even though some of the pointers aren't objects and this doesn't seem quite correct but since I'm using GC NSPointerFunctionsObjectPointerPersonality seems nearly equivalent to NSPointerFunctionsOpaquePersonality as long as description isn't called.

--
Michael

On Oct 15, 2008, at 1:08 AM, Ken Ferry wrote:

Hi Michael,

NSPointerFunctionsStrongMemory|NSPointerFunctionsOpaqueMemory doesn't
make sense. You're meant to specify only one of the memory options and
only one of the personality options.

Due to the way the bitfield work, your invocation is the same as
NSPointerFunctionsOpaqueMemory|NSPointerFunctionsOpaquePersonality.
This is the mode in which the pointer array is completely hands-off.
It acts like a C array.

Try NSPointerFunctionsStrongMemory| NSPointerFunctionsOpaquePersonality.
That sounds right to me, though I get confused with the pointer
functions too.

-Ken

On Tue, Oct 14, 2008 at 9:43 PM, Michael Link <[EMAIL PROTECTED]> wrote:
I have a situation where I create an NSPointerArray on the stack by:

pointers = [NSPointerArray
pointerArrayWithOptions:NSPointerFunctionsStrongMemory| NSPointerFunctionsOpaqueMemory|NSPointerFunctionsOpaquePersonality];

I then go about adding a few objects a selector and a pointer (contextInfo
that could point to anything even a non-object) to the pointer array.

I then call:

[[NSGarbageCollector defaultCollector] disableCollectorForPointer:pointers];

The pointer array is then passed as the contextInfo for another method (which turns out to be a weak reference), but isn't garbage collected due to the previous call. The interesting part turns out that the object at index 0 (NSError* in this case) in the pointer array is garbage collected (probably because it was a variable in the function that called us). The pointer array is configured to use strong references therefore index 0 isn't set to NULL and something else is located at that memory (sometimes a different object,
sometimes garbage memory).

If I use:

[[NSGarbageCollector defaultCollector] disableCollectorForPointer: [pointers
pointerAtIndex:0]];

nothing bad happens and that object isn't collected.

According to the documentation for disableCollectorForPointer: shouldn't the pointer array be considered a new root object, and none of it's pointers
collected? Especially since it uses strong references?

--
Michael
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/kenferry%40gmail.com

This email sent to [EMAIL PROTECTED]




_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to