Re: Deep Recursion
Re: Deep Recursion
- Subject: Re: Deep Recursion
- From: "Michael Ash" <email@hidden>
- Date: Thu, 28 Aug 2008 11:38:27 -0400
On Wed, Aug 27, 2008 at 10:01 PM, Gerriet M. Denkmann
<email@hidden> wrote:
> Yesterday I did some nice recursive programming - the only problem was: I
> did not intend to do so.
> As a consequence, there was no defined end to the recursion, which made it
> essentially infinite.
>
> Well, memory - specifially stack space - is not infinite, so eventually I
> got an EXEC_BAD_ADDR or something like it.
>
> The real problem: while happily recursing away, the virtual memory exceeded
> all bounds of propriety, the swap files grew beyond all reasonable limits
> and the whole computer became (almost) unusable.
> I could not kill the runaway app from Xcodes Stop button - I had to wait
> until the aforementioned exception did take place.
> At which point gdb was started and offered to load some 50 000 stack frames,
> politely giving me the option to decline.
>
> Is there some way (environment variable?) to limit the stack size to
> something smaller, so that the exception (probably from stack corruption)
> would show off earlier?
The stack is not so big as that.
What probably caused the system slowdown was all the temporary objects
you were allocating (I assume) and which never went away, on account
of you never getting to the point of releasing any autorelease pools.
Your stack is only a few (dozen?) megabytes at most, so using all of
it shouldn't cause the symptoms you describe. But if each stack
creates a bunch of autoreleased temporary objects, they will all stick
around until you crash because the system is waiting for you to return
before it destroys them.
Unfortunately Mac OS X tends to behave badly in the face of this sort
of extreme memory pressure, and I'm not sure how to make it work any
better. If you happen to have two computers running, it can be useful
to get in the habit of keeping an ssh session open to your development
machine. Often a runaway process such as this which makes the GUI
unusable doesn't affect the command line nearly so much, so you can go
in and do a quick 'killall Whateverapp' to get back to normality.
Mike
_______________________________________________
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
References: | |
| >Deep Recursion (From: "Gerriet M. Denkmann" <email@hidden>) |