且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

由于重复调用函数而导致堆栈溢出异常

更新时间:2023-08-22 08:44:28

递归:参见递归。



如果你拿一张纸,并在两边写上请翻身,你可以把它交给一个白痴,让他们逗乐数小时。任何更明亮的人都会看到两个,也许是三个方面,他们的筹码将耗尽,他们会厌恶和无聊地放下它。

这就是这里发生的事情:每次调用Save函数时,返回地址被压入堆栈(因此它知道在Save完成时返回的位置),然后再次调用Save函数。这会导致返回地址被压入堆栈(因此它知道在Save完成时返回的位置),然后再次调用Save函数。这导致...



直到堆栈耗尽并且你得到一个例外。并且您的网站崩溃了。
Recursion: see "Recursion".

If you take a sheet of paper, and write "please turn over" on both sides, you can hand it to an idiot and keep them amused for hours. Anyone brighter will look at two, perhaps three sides and their stack will run out and they will put it down in disgust and boredom.
That's what's happening here: every time you call the Save function, the return address is pushed onto the stack (so it knows where to come back to when Save finishes), and it then calls the Save function again. This causes the return address to be pushed onto the stack (so it knows where to come back to when Save finishes), and it then calls the Save function again. This causes...

Until the stack runs out and you get an exception. And your site crashes.