From ae1b57499712273f9f5f28bf12847bed16ff5ad9 Mon Sep 17 00:00:00 2001 From: Steven Luo Date: Sun, 29 May 2011 17:47:24 -0700 Subject: [PATCH] Dispose of IRCConnections properly to avoid leaking IRCService objects Each IRCConnection starts an input thread and an output thread when created; if not stopped, these threads continue to hold the IRCService, resulting in a leak when the service is stopped. Fix this by using PircBot's dispose() to stop the threads when disposing of the IRCConnection. --- application/src/org/yaaic/irc/IRCService.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/application/src/org/yaaic/irc/IRCService.java b/application/src/org/yaaic/irc/IRCService.java index 9ffcb3a..499de71 100644 --- a/application/src/org/yaaic/irc/IRCService.java +++ b/application/src/org/yaaic/irc/IRCService.java @@ -372,7 +372,14 @@ public class IRCService extends Service for (int i = 0; i < mSize; i++) { server = mServers.get(i); if (server.isDisconnected()) { - connections.remove(server.getId()); + int serverId = server.getId(); + synchronized(this) { + IRCConnection connection = connections.get(serverId); + if (connection != null) { + connection.dispose(); + } + connections.remove(serverId); + } } else { shutDown = false; }