Java堆栈溢出错误 - 如何在Eclipse中增加堆栈大小? [英] Java stack overflow error - how to increase the stack size in Eclipse?
问题描述
线程main java.lang.StackOverflowError
这可以通过增加Java堆栈大小来解决吗?我在Eclipse中这样做?
更新:
@Jon Skeet
代码以递归方式遍历解析树,以构建数据结构。因此,例如,代码将使用解析树中的节点进行一些工作,并在节点的两个子节点上调用自己的结果,结合其结果给出树的总体结果。
递归的总深度取决于解析树的大小,但是当递归调用次数达到1000s时,代码似乎失败(没有较大的堆栈)。
另外我很确定代码没有失败,因为它适用于小的输入。
为您的应用程序打开运行配置(运行/运行配置...,然后在Java应用程序中查找应用程序条目)。
参数选项卡有一个文本框 Vm参数,输入 -Xss1m
(或更大的参数最大堆栈大小)。默认值为512 kByte(SUN JDK 1.5 - 不知道供应商和版本之间是否不同)。
I am running a program that I've written in Java in Eclipse. The program has a very deep level of recursion for very large inputs. For smaller inputs the program runs fine however when large inputs are given, I get the following error:
Exception in thread "main" java.lang.StackOverflowError
Can this be solved by increasing the Java stack size and if so, how do I do this in Eclipse?
Update:
@Jon Skeet
The code is traversing a parse tree recursively in order to build up a datastructure. So, for example the code will do some work using a node in the parse tree and call itself on the node's two children, combining their results to give the overall result for the tree.
The total depth of the recursion depends on the size of the parse tree but the code seems to fail (without a larger stack) when the number of recursive calls gets into the 1000s.
Also I'm pretty sure the code isn't failing because of a bug as it works for small inputs.
Open the Run Configuration for your application (Run/Run Configurations..., then look for the applications entry in 'Java application').
The arguments tab has a text box Vm arguments, enter -Xss1m
(or a bigger parameter for the maximum stack size). The default value is 512 kByte (SUN JDK 1.5 - don't know if it varies between vendors and versions).
这篇关于Java堆栈溢出错误 - 如何在Eclipse中增加堆栈大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!