Java 中的堆栈溢出错误

发布于 2024-11-27 07:45:12 字数 272 浏览 1 评论 0原文

可能的重复:
什么是堆栈溢出错误?

出现 StackOverflowError 时意味着什么在Java中?

java.lang.StackOverflowError: null

Possible Duplicate:
What is a stack overflow error?

What does it mean when there is a StackOverflowError in Java?

java.lang.StackOverflowError: null

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

甜柠檬 2024-12-04 07:45:12

根据 Java API Documentations for the StackOverflowError< /code> class,“当由于应用程序递归太深而发生堆栈溢出时”会抛出此错误。

According to the Java API Documentations for the StackOverflowError class, this error is thrown "when a stack overflow occurs because an application recurses too deeply".

醉梦枕江山 2024-12-04 07:45:12

通常意味着存在一个递归函数,其中结束条件永远不会发生。它会运行,填充堆栈,直到出现 StackOverflowError。

Usually means there is a recursive function where the end condition never happens. It runs, filling the stack, until you get a StackOverflowError.

岛歌少女 2024-12-04 07:45:12

这意味着您已将太多帧推送到 Java 解释器堆栈上。 JVM 可以处理相当深的嵌套函数深度,但迟早您需要划清界限并说:“如果您嵌套的东西比这更深,您的程序可能会行为不当”。你越过了那条线。

查看是否使用任何递归函数调用,然后在其循环等效项中重写它们(如果需要)。不必要的递归函数是引发堆栈溢出异常的 90% 原因。另外,请记住,Java(尚未)优化尾端递归(这是其他环境避免堆栈溢出/失控堆栈增长的方式)。

It means that you have pushed too many frames onto the Java interpreter stack. The JVM can handle a depth of nested functions that goes pretty deep, but sooner or later you need to draw the line in the sand and say, "if you nest things deeper than this, your program is probably misbehaving". You crossed that line.

See if you're using any recursive function calls, then rewrite them in their looping equivalents (if necessary). Unnecessarily recursive functions are 90% of the reasons you throw a stack overflow exception. Also, keep in mind that Java doesn't (yet) optimize tail end recursion (which is how other environments avoid stack overflows / runaway stack growth).

樱娆 2024-12-04 07:45:12

这意味着堆栈(系统跟踪已执行内容的方式)已溢出(尝试放入的内容超出了允许的内容)。这通常意味着您有一个无法控制地调用自身的递归操作。

It means that the stack (the way the system keeps track of what has been executed) has overflowed (more was attempted to put on in than was allowed). This frequently means that you've got a recursive operation that's uncontrollably calling itself.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文