【问题标题】:Unirest Thread LeakUnirest 线程泄漏
【发布时间】:2020-04-06 02:35:42
【问题描述】:

我的网络应用程序似乎内存不足,我认为这是由于线程泄漏。似乎线程被卡在等待中,并且越来越大,直到内存达到堆大小的顶部。在空闲且不使用 Web 应用程序时,我的本地 Tomcat 服务器上的 Web 应用程序的线程大小会增加。我对线程泄漏不是很了解,但我确信线程应该被释放以释放分配的内存。

我已经进行了线程转储,其中很多线程正在 com.mashape.unirest.http.utils.SyncIdleConnectionMonitorThread 上等待,如下所示。

"Thread-124" - Thread t@378
java.lang.Thread.State: TIMED_WAITING
at java.lang.Object.wait(Native Method)
- waiting on <44c53e01> (a com.mashape.unirest.http.utils.SyncIdleConnectionMonitorThread)
at com.mashape.unirest.http.utils.SyncIdleConnectionMonitorThread.run(SyncIdleConnectionMonitorThread.java:22)

Locked ownable synchronizers:
- None

"Thread-122" - Thread t@371
java.lang.Thread.State: TIMED_WAITING
at java.lang.Object.wait(Native Method)
- waiting on <3212c7ae> (a com.mashape.unirest.http.utils.SyncIdleConnectionMonitorThread)
at com.mashape.unirest.http.utils.SyncIdleConnectionMonitorThread.run(SyncIdleConnectionMonitorThread.java:22)

Locked ownable synchronizers:
- None

任何解决此问题的有用提示将不胜感激。

【问题讨论】:

    标签: java multithreading unirest


    【解决方案1】:

    这似乎是 mashape Unirest 中的一个错误,如果您创建多个 unirest 实例,它不会关闭线程。

    我已经开始使用 konghq 版本的 unirest,它已经解决了这个问题。

    可以在这里找到:https://mvnrepository.com/artifact/com.konghq/unirest-java

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-10-05
      • 2014-10-29
      • 2011-09-13
      • 2013-12-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-04
      相关资源
      最近更新 更多