0

I wrote a javaCC parser for some propositional logic expressions. The expressions can get pretty long, 30k many characters.

When I parse such big expressions, I get a stack-overflow exception.

Is there maybe some VM parameter which determines the stack size?

Or what would you do in such cases?

Thanks

2 Answers 2

4

Yes, use the -Xss parameter. e.g.:

java -Xss4m Blah

sets the stack-size to 4MB.

Sign up to request clarification or add additional context in comments.

Comments

1

While you can alter the stack size as per Oli's answer, I would suggest you try to look for an alternative approach which doesn't recurse so deeply. For example, you might want to build a stack or queue of "results so far" or whatever, to mimic the recursion but using heap space instead of using stack space. Increasing the VM stack size always strikes me as a "solution" which is just delaying the problem a bit.

(It also means that if you end up with stack traces, they'll be monstrous... whereas if you use appropriate diagnostics for the stack of "things you're looking at" you can end up with data-driven diagnostics instead of ones based on stack frames.)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.