Re: Increasing stack size of NSDocument's open file thread
Re: Increasing stack size of NSDocument's open file thread
- Subject: Re: Increasing stack size of NSDocument's open file thread
- From: Jens Alfke <email@hidden>
- Date: Thu, 6 Jul 2017 09:44:20 -0700
> On Jul 6, 2017, at 8:42 AM, Steve Mills <email@hidden> wrote:
>
> Why can't you spawn your own thread to do the recursive code? Create the
> NSThread, set its stack size, light its fuse to do the processing, and delete
> it.
This. Although I would also consider looking at your code to see if it can be
refactored to avoid using recursion; a recursive algorithm can always be turned
into an iterative one that uses a (growable) stack data structure to hold
state. Unbounded recursion can be dangerous, especially when it’s operating on
external data. If you do stick with the custom-thread approach, consider
putting in an explicit recursion-depth check in your code so you can abort it
cleanly before blowing up the stack.
—Jens
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden