我的网络应用程序似乎内存不足,我认为这是由于线程泄漏。线程似乎一直在等待,并且越来越大,直到内存达到堆大小的顶部。在空闲且不使用 Web 应用程序时,Web 应用程序的本地 Tomcat 服务器上的线程大小会增加。我对线程泄漏没有很好的理解,但我确信线程应该被释放以释放分配的内存。
我进行了线程转储,其中很多线程都在 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
Run Code Online (Sandbox Code Playgroud)
任何解决此问题的有用提示将不胜感激。
我正在将这个双精度数转换为字符串,以便可以将其显示在 TextView 上。我希望使用 String.format 使字符串具有 2 个小数位,但我不知道将其放在这行文本中的何处。
Example.setText(Double.toString(dValue));
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?