java - 在 Debug模式下计算实例化类的数量失败

标签 java virtual-machine kotlin allocation connection-refused

在 kotlin 中使用 imgui 端口工作时,我有一个 metrics 菜单,在其中显示分配数量

这是init code我写道:

    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<String, Argument>(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")
    }

这些是我作为“VM 选项”传入的参数

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

只要我正常运行它,它就可以工作。但如果我在 Debug模式下运行它,它不会,返回以下错误:

java.net.ConnectException: Connection refused: connect

我还找不到解决方案,目前我只是显示 -1 来指示错误

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

规范:

  • Kotlin 1.2-m1
  • 想法2017.2.1

最佳答案

我猜问题是您尝试为调试器使用与程序使用的端口相同的端口。尝试为调试器使用不同的端口。

关于java - 在 Debug模式下计算实例化类的数量失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45509344/

相关文章:

java - 长时间运行的操作的状态应该存储在哪里?

java - 在Jar文件中修改

java - 是否可以获得 wit.ai 的 JAVA SDK?

windows - 我如何确定我的进程是 CPU 绑定(bind)、I/O 绑定(bind)、内存绑定(bind)还是

virtual-machine - 重命名 Google Compute Engine 虚拟机实例

android - 将 jetpack compose 添加到现有项目

java - 使用 Objectweb ASM 字节码增加 Java Fied 值

sql-server - 更改 Azure VM 上的 SQL Server 版本

android - 用于 Jetpack Compose 中分页项目的 LazyVerticalGrid

安卓撰写 : Type is defined multiple times