4

I've created a POC for the Watson TTS service in Eclipse using the Java SDK 3.3.0. The app server is Tomcat v8.0 running locally through Eclipse on a Win10 PC. Everything works fine, i.e., it is able to retrieve an audio stream, but when I stop Tomcat I'm seeing warnings about memory leaks. Here are two of the messages:

The web application [testapp] appears to have started a thread named [OkHttp ConnectionPool] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:

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've looked through the SDK and can't find anything about exiting the TextToSpeech connection gracefully. Is this cause for concern? If I add this service to the production website it will be running in a Sun Solaris 10 environment also with Tomcat8.

German Attanasio
  • 22,217
  • 7
  • 47
  • 63
LWK69
  • 1,070
  • 2
  • 14
  • 27

1 Answers1

0

After some investigations, I realized that those warnings are generated because the IBM Watson Java SDK uses OkHttp, and it creates asynchronous threads to handle the connection pool and the different request.

There are good reasons of why this is the way it is and they also suggest how to reuse the OkHttpClient to create fewer threads. I'm working on that as part of #686.

If you want to know more take a look at this issue in the OkHttp repository.

I'm about to release a new version of the Java SDK (v3.8.1) which reuses the OkHttpClient instance and therefore creates fewer threads.

German Attanasio
  • 22,217
  • 7
  • 47
  • 63