0

I am using hosebird client in java to get real time tweets using using twitter streaming api.

After few hours while running it giving below exception.

18-Jul-2017 15:35:50.034 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [ROOT] appears to have started a thread named [hosebird-client-io-thread-0] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 java.net.SocketInputStream.socketRead0(Native Method)
 java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
 java.net.SocketInputStream.read(SocketInputStream.java:171)
 java.net.SocketInputStream.read(SocketInputStream.java:141)
 sun.security.ssl.InputRecord.readFully(InputRecord.java:465)
 sun.security.ssl.InputRecord.read(InputRecord.java:503)
 sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:983)
 sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:940)
 sun.security.ssl.AppInputStream.read(AppInputStream.java:105)
 org.apache.http.impl.io.AbstractSessionInputBuffer.fillBuffer(AbstractSessionInputBuffer.java:166)
 org.apache.http.impl.io.SocketInputBuffer.fillBuffer(SocketInputBuffer.java:90)
 org.apache.http.impl.io.AbstractSessionInputBuffer.readLine(AbstractSessionInputBuffer.java:281)
 org.apache.http.impl.conn.LoggingSessionInputBuffer.readLine(LoggingSessionInputBuffer.java:115)
 org.apache.http.impl.io.ChunkedInputStream.getChunkSize(ChunkedInputStream.java:251)
 org.apache.http.impl.io.ChunkedInputStream.nextChunk(ChunkedInputStream.java:209)
 org.apache.http.impl.io.ChunkedInputStream.read(ChunkedInputStream.java:171)
 org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:138)
 java.util.zip.InflaterInputStream.fill(InflaterInputStream.java:238)
 java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158)
 java.util.zip.GZIPInputStream.read(GZIPInputStream.java:117)
 com.twitter.hbc.common.DelimitedStreamReader.readLine(DelimitedStreamReader.java:72)
 com.twitter.hbc.common.DelimitedStreamReader.readLine(DelimitedStreamReader.java:56)
 com.twitter.hbc.core.processor.StringDelimitedProcessor.processNextMessage(StringDelimitedProcessor.java:53)
 com.twitter.hbc.core.processor.StringDelimitedProcessor.processNextMessage(StringDelimitedProcessor.java:26)
 com.twitter.hbc.core.processor.AbstractProcessor.process(AbstractProcessor.java:46)
 com.twitter.hbc.httpclient.Connection.processResponse(Connection.java:51)
 com.twitter.hbc.httpclient.ClientBase.processConnectionData(ClientBase.java:244)
 com.twitter.hbc.httpclient.ClientBase.run(ClientBase.java:144)
 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
 java.lang.Thread.run(Thread.java:748)

I tried to change the hosebird-client-thread to daemon thread as mentioned here, still no luck.

public static Thread getThreadByName(String threadName) {
    for (Thread t : Thread.getAllStackTraces().keySet()) {
        System.out.println("Thread is: "+ t.getName());
        if (t.getName().contains(threadName)) return t;
    }
    return null;
}

getThreadByName("hosebird-client-io-thread").setDaemon(true);

Any lead would greatly appreciated!

2
  • Post your code snippet where you are initializing the client and do some operation on it. My guess is you have forgotten to shut down the client in some flow. Jul 20, 2017 at 12:12
  • Yeah you are right, I stoped the client and just after that restared the client! Jul 21, 2017 at 7:53

1 Answer 1

0

Fixed the memory leak for the thread by stopping it when it doesn't required any more and restart again.

if(hosebirdClient.isDone())
        {
            hosebirdClient.stop();
            updateSystmeParameters(0, getCurrentTimeStamp(), "NA");
            Search.startFirehoseFilter(); // this function restart the thread 

        }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.