Watson Java SDK and OkHttp memory acceleration

I created a POC for the Watson TTS service in Eclipse using the Java SDK 3.3.0. Application Server - Tomcat v8.0, working locally through Eclipse on a Win10 PC. Everything works fine, i.e. It can extract the audio stream, but when I stop Tomcat, I see warnings about memory leaks. Here are two posts:

The [testapp] web application seems to have started a thread named [OkHttp ConnectionPool], but could not stop it. This will likely lead to a memory leak. Trace flow stream:

java.lang.Object.wait(Native Method)
java.lang.Object.wait(Object.java:461) 
okhttp3.ConnectionPool$1.run(ConnectionPool.java:66)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) java.lang.Thread.run(Thread.java:745)

There is a similar message for [Okio Watchdog].

I looked through the SDK and cannot find anything about exiting the TextToSpeech connection gracefully. Is this a concern? If I add this service to the website, it will work in the Sun Solaris 10 environment with Tomcat8.

+4
source share
1 answer

After some research, I realized that these warnings are generated because the IBM Watson Java SDK uses OkHttp and it creates asynchronous threads to process the connection pool and other request.

There are good reasons why this is the case, and they also suggest how to reuse OkHttpClientto create fewer threads. I am working on this as part of # 686 .

If you want to know more, check out this problem in the OkHttp repository.

Java SDK (v3.8.1), OkHttpClient .

0

Source: https://habr.com/ru/post/1654025/


All Articles