On May 28, 2012, at 10:08 PM, James Maxwell wrote:

> Well, yes, that's what happens. In fact, it's much hairier than that! There's 
> actually an array of parentNodes, not just one. It's a complex graph, as I 
> mentioned, not a straightforward tree (which would already contain mutual 
> parent/child references, it seems to me). In my structure, there are about 
> three dimensions of this kind of referencing, allowing me to move around the 
> graph in useful ways…

I suspect this isn't a bug in Foundation, so much as a scaling limit that 
you've exceeded with the complexity of the object graphs you write out. You've 
inadvertently found a way to get the graph traversal done by the unarchiver to 
recurse to arbitrarily deep levels, by generating graphs that have arbitrarily 
long non-cyclic paths through them.

I suggest writing out simpler object graphs.

One place you can start is by _not_ archiving the back-pointers. You can 
reconstruct those in the -initWithCoder method. For example, after a parent 
node unarchives its array of children, it can call each child to tell it, in 
effect, "who's your daddy?" so the child can initialize its parent pointer.

In general, look at your graph and figure out the minimum number of object 
relations you need to archive to reconstruct its structure. Then archive only 
those, and recreate the rest at load time.

(Another possibility is to work around this by creating a pthread with a really 
huge stack size limit, and doing the unarchiving on that thread. But I bet 
it'll be slow. Your users would probably rather you simplified the object graph 
and made opening documents faster.)

—Jens

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to