AnsweredAssumed Answered

Lot of Memory Leaks with Smack 3.4.0

Question asked by CSH Champion on Feb 5, 2014
Latest reply on Feb 6, 2014 by Flow

Hi,

 

I've been experiencing a lot of Memory Leaks with Smack 3.4.0.

 

If I run the following test class, a lot of instances are kept in memory. See the attached VisualVM image.

I suspect the listeners are not cleared during disconnecting.

 

These problem didn't occur with Smack 3.3.1.

 

public class SmackTest {

 

    public static void main(String[] args) {

        // Create the main application thread, that will run forever and will keep the program alive.

        System.out.println(SmackConfiguration.getVersion());

        Executors.newFixedThreadPool(1, new ThreadFactory() {

            @Override

            public Thread newThread(Runnable r) {

                return new Thread(r, "Main Application Thread");

            }

        }).execute(new Runnable() {

            @Override

            public void run() {

 

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

                    Connection connection = new XMPPConnection(new ConnectionConfiguration("server", 5222));

                    System.out.println("Connecting...");

                    try {

                        connection.connect();

                    } catch (XMPPException e) {

                        e.printStackTrace();

                    } finally {

                        connection.disconnect();

                    }

                }

            }

        });

 

    }

}

Attachments

Outcomes