how to expand size of Java stack trace to see bottom of stack? (triggering a stack overflow)

后端 未结 4 1793
傲寒
傲寒 2020-12-18 22:25

In Java, is there any way to view the complete, untruncated stack trace (e.g. by increasing the number of frames recorded), or otherwise get at the bottom of a stac

相关标签:
4条回答
  • 2020-12-18 22:48

    If you have access to the call before it is entering the suspected stack overflow, you could just generate an additional stack trace like new Exception().getStackTrace. Note that foldRight itself won't produce an infinite recursion. Maybe you just run out of memory, try increasing the JVM's stack size.

    0 讨论(0)
  • 2020-12-18 22:59

    Try the -XX:MaxJavaStackTraceDepth JVM option.

    Here is a description from Stas's Blog

    Max. no. of lines in the stack trace for Java exceptions (0 means all). With Java > 1.6, value 0 really means 0. value -1 or any negative number must be specified to print all the stack (tested with 1.6.0_22, 1.7.0 on Windows). With Java <= 1.5, value 0 means everything, JVM chokes on negative number (tested with 1.5.0_22 on Windows).

    0 讨论(0)
  • 2020-12-18 23:05

    You can iterate over the stack trace yourself

    Throwable t =
    
    for(StackTraceElement ste: t.getStackTrace()) {
        // is it a repeat??
    
    }
    

    The default printStackTrace will print every level which has been recorded. Your problem is that the stack is too deep for what it put in the stack trace.

    Can you try reducing your stack size?

    0 讨论(0)
  • 2020-12-18 23:08

    Try using jstack:

    http://docs.oracle.com/javase/6/docs/technotes/tools/share/jstack.html

    http://docs.oracle.com/javase/7/docs/webnotes/tsg/TSG-VM/html/tooldescr.html#gblfh

    0 讨论(0)
提交回复
热议问题