在调试模式下计算实例类的数量失败

在kotlin的imgui端口上工作,我有一个metrics菜单,显示分配数量

这是我写的init代码 :

  try { var ac: AttachingConnector? = null for (x in Bootstrap.virtualMachineManager().attachingConnectors()) { if (x.javaClass.name.toLowerCase().indexOf("socket") != -1) { ac = x break } } if (ac == null) { throw Error("No socket attaching connector found") } val connectArgs = HashMap(ac.defaultArguments()) connectArgs["hostname"]!!.setValue("127.0.0.1") connectArgs["port"]!!.setValue(Integer.toString(3001)) connectArgs["timeout"]!!.setValue("3000") vm = ac.attach(connectArgs) } catch (error: Exception) { System.err.println("Couldn't retrieve the number of allocations, $error") } 

这些都是我通过“虚拟机选项”

-Xdebug -Xrunjdwp:transport=dt_socket,address=3001,server=y,suspend=n

每当我正常运行它,它的作品。 但是,如果我在调试模式下运行它,它不会返回以下错误:

java.net.ConnectException:连接被拒绝:连接

我找不到解决方案,目前我只显示一个-1来表示错误

有没有人有解决方案/解释?

眼镜:

  • Kotlin 1.2-m1
  • 理念2017.2.1

我想问题是你试图使用相同的端口的调试程序使用的程序。 尝试为调试器使用不同的端口。