如何扩展Java堆栈跟踪的大小看堆栈的底部? (触发堆栈溢出) [英] how to expand size of Java stack trace to see bottom of stack? (triggering a stack overflow)

查看:239
本文介绍了如何扩展Java堆栈跟踪的大小看堆栈的底部? (触发堆栈溢出)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Java中,是否有任何方法可以查看完整的未经截断的堆栈跟踪(例如,通过增加记录的帧数),或以其他方式获取堆栈跟踪的底部?通常,堆栈跟踪将从顶部截取1024个帧值,但是对于堆栈溢出问题,这是非常无价值的,因为您真的需要查看谁触发了递归的呼叫,接近底部。更好的是在堆栈的中间中截断,但显然Sun的JVM不够聪明。

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 stack trace? Normally the stack trace is truncated from the top at 1024 frames worth, but for a stack overflow problem this is fairly worthless as you really need to see who made the call that triggered the recursion, down near the bottom. Much better would truncation in the middle of the stack, but evidently Sun's JVM isn't smart enough to do this.

甚至可能还有一些特别的太阳标志?我尝试将堆栈大小减小到最小允许值(-Xss1000),但仍然超过1024帧。

Perhaps even some special Sun-specific flags? I tried reducing the stack size to the minimum allowable (-Xss1000) but that's still more than 1024 frames worth.

在我的情况下,我正在尝试调试堆栈在Hadoop映射器中发生的溢出,但只有在真正大的输入时运行。我假设问题来了,因为一个递归操作(Scala的 foldRight )正在一个非常大的链表上完成,我需要非递归地重写它...但是我需要知道谁打电话给 foldRight 。这是一个基本的例程,直接和间接地在许多地方,有很多很多的代码,我正在使用,所以这是非常不明显的。

In my case, I'm trying to debug a stack overflow that occurs in a Hadoop mapper, but only when running on really large input. I assume the problem comes because a recursive operation (Scala's foldRight) is being done on a really, really large linked list, and I need to rewrite it non-recursively ... but I need to know who made the call to foldRight. This is a basic routine called directly and indirectly in a lot of places and there's lots and lots of code out there that I'm working with, so this is highly non-obvious.

推荐答案

尝试 -XX:MaxJavaStackTraceDepth JVM选项。

以下是 Stas的博客


没有。在Java异常的堆栈跟踪中的行(0表示全部)。
使用Java> 1.6,值0真的意味着0.值-1或任何负数必须指定打印所有的堆栈(测试与1.6.0_22,在Windows上为1.7.0)。
使用Java< = 1.5,值0表示所有内容,JVM阻塞负数(Windows上为1.5.0_22进行测试)。

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).

这篇关于如何扩展Java堆栈跟踪的大小看堆栈的底部? (触发堆栈溢出)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆