How to track down seemingly random crashes in Java?

筅森魡賤 提交于 2019-12-11 03:29:01

问题


While doing some homework that works with some swing gui components, my program started crashing seemingly at random. That is, it starts, runs for a short time, and then crashes. I don't get any errors in the console, it's just a straight up crash.

I don't doubt that it is something I wrote, and I'm more than happy to show code if anyone wants to look at it, but is there anything that I can do myself to track down what might be the cause of my crashes?

Some other information that might be useful:

  • I'm using eclipse, and the debugger doesn't seem to do anything that helps me with this (program still crashes).
  • I didn't notice any issues like this until I started to add event handling.
  • I'm using Windows 10.
  • Occasionally, nothing is drawn in the window I create. Exiting and then running the program again will cause it to work.

回答1:


Some possible heuristics:

  • Crashes that occur seemingly at random suggest incorrect synchronization; look for event dispatch thread violation using one of the approaches cited here.

  • Verify that all exception handlers produce diagnostic output; run from the command line to ensure that diagnostic output has not been inadvertently redirected.

  • Try running under the aegis of a different debugger, e.g. NetBeans.

  • Try running under the aegis of a profiler.

  • Try a different version of the JDK/JRE.

  • Try a different host OS.



来源:https://stackoverflow.com/questions/30207220/how-to-track-down-seemingly-random-crashes-in-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!