powered by Jive Software

Memory Leak in BookmarkManager


we currently have huge troubles with Memory Leaks. While working on the cause, I’ve found that one cause is Smack’s BookmarkManager.

It keeps connections in it’s static HashMap and doesn’t use weak references (as other manager classes do).

Therefore connections are kept in memory after disconnecting/losing reference to them and everything else, what is attached to a connection, too (like other manager classes). See attached screenshot from VisualVM.

Reproducible with this code (tested with 3.3.1 and 3.4.1):

public class SmackTest {

public static void main(final String[] args) {

Executors.newFixedThreadPool(1, new ThreadFactory() {


public Thread newThread(Runnable r) {

return new Thread(r, “Main Application Thread”);


}).execute(new Runnable() {


public void run() {


for (int i = 0; i < 10; i++) {

System.out.println(“Connecting…” + i);

Connection connection = new XMPPConnection(“server”);

try {


connection.login(“admin”, “admin”);


} catch (XMPPException e) {


} finally {








Thanks for reporting, logged as SMACK-554