日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

抓住尾部的StackOverFlowError

發布時間:2023/12/3 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 抓住尾部的StackOverFlowError 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
使用Java程序時可能要處理的一種更煩人的情況是StackOverFlowError,如果您有一個很好的可生產的測試用例,那么關于使用堆棧大小或設置條件斷點/某種痕跡 。

但是,如果您有一個測試案例可能一次失敗100次,或者像我的案例一樣在AWTMulticaster中出現競爭情況,那么您想改善診斷。 問題是默認情況下,在前1024個條目之后,VM不會在堆棧跟蹤中包含任何元素。 (至少對于JDK 6而言)因此,如果運行以下簡單示例:

package other;public class Overflow {public static final void call(double a, double b, double c, double d) {call(a,b,c,d);}public static void main(String[] args) {call(0,0,0,0);}}

在找到問題原因之前,輸出將停止,這使得解決問題非常困難。

> java other.Overflow Exception in thread "main" java.lang.StackOverflowErrorat other.Overflow.call(Overflow.java:7)at other.Overflow.call(Overflow.java:7)at other.Overflow.call(Overflow.java:7)at other.Overflow.call(Overflow.java:7)at other.Overflow.call(Overflow.java:7)at other.Overflow.call(Overflow.java:7)at other.Overflow.call(Overflow.java:7)at other.Overflow.call(Overflow.java:7)[ lots of lines removed ]at other.Overflow.call(Overflow.java:7)at other.Overflow.call(Overflow.java:7)at other.Overflow.call(Overflow.java:7)at other.Overflow.call(Overflow.java:7)at other.Overflow.call(Overflow.java:7)at other.Overflow.call(Overflow.java:7) Process exited with exit code 1.

好消息是,此限制是啟動虛擬機時可以調整的許多正式和非正式的內容之一。

> java -XX:MaxJavaStackTraceDepth=1000000 other.Overflow Exception in thread "main" java.lang.StackOverflowErrorat other.Overflow.call(Overflow.java:7)at other.Overflow.call(Overflow.java:7)at other.Overflow.call(Overflow.java:7)at other.Overflow.call(Overflow.java:7)at other.Overflow.call(Overflow.java:7)at other.Overflow.call(Overflow.java:7)at other.Overflow.call(Overflow.java:7)at other.Overflow.call(Overflow.java:7)[ lots of lines removed ]at other.Overflow.call(Overflow.java:7)at other.Overflow.call(Overflow.java:7)at other.Overflow.call(Overflow.java:7)at other.Overflow.call(Overflow.java:7)at other.Overflow.call(Overflow.java:7)at other.Overflow.main(Overflow.java:12) Process exited with exit code 1.

請注意,堆棧的末尾現在包含了問題的根源,在嘗試診斷問題時將非常有用。

您可能不想長期在生產服務器上設置此屬性,因為我不確定它的影響。 查看C ++代碼,似乎這只是一個最大值,不會影響大多數其他堆棧跟蹤,因為它們在32個條目的段中的鏈接列表中分配。

參考:在Gerard Davison的博客博客中,從我們的JCG合作伙伴 Gerard Davison 的尾部捕獲了StackOverFlowError 。


翻譯自: https://www.javacodegeeks.com/2012/07/catch-stackoverflowerror-by-its-tail.html

總結

以上是生活随笔為你收集整理的抓住尾部的StackOverFlowError的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。