代码中罕见的无限循环,不想等待它再次发生 [英] Rare infinite loop in code, don't want to wait for it to happen again

查看:131
本文介绍了代码中罕见的无限循环,不想等待它再次发生的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,所以我有一个在netbeans中运行的遗传算法,它运行了5个小时,似乎已经进入了一个无限循环。有什么办法可以附加一个调试器吗?或至少得到一些线索,代码中的哪里?我不想再坐5个小时,而我等待再次发生。

解决方案

一个简单的方法来获取运行程序的一些基本信息是运行 jstack ,它将打印代码中所有线程的堆栈跟踪。做几次,你应该知道什么是错误的。



使用 jps 来查找JVM的id,然后使用 jstack 与该ID:

  $ jps 
10664 Jps
7141 org.eclipse.equinox.launcher_1.2.0.v20110124-0830.jar
$ jstack 7141

VisualVM 提供类似的信息,如果您喜欢GUI应用程序。


Ok, so I've got a genetic algorithm running in netbeans, and its been running for like 5 hours and seems to have entered an infinite loop. Is there any way that I can attach a debugger to it? or at least get some clue as to where it is in the code? I'd rather not sit around for another 5 hours while I wait for it to happen again.

解决方案

A simple way to get some basic information from your running program is to run jstack on it, it will print stack traces of all threads in your code. Do that several times and you should have a good idea what is wrong.

Use jps to find out the id of your JVM like and then use jstack with that ID:

$ jps
10664 Jps
7141 org.eclipse.equinox.launcher_1.2.0.v20110124-0830.jar
$ jstack 7141

VisualVM provides similar information, if you prefer a GUI application.

这篇关于代码中罕见的无限循环,不想等待它再次发生的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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