Smack OutOfMemoryError

Folks,

Anyone seeing memory leaks in their Smack 3.1.0 based apps? I keep running into this issue, it looks like messages sent to MUC are causing memory to grow until heap space is full.

Thanks,

BEA

looks related to a bug reported already.

http://www.igniterealtime.org/issues/browse/SMACK-129

Folks,

Knowing that Smack 3.1.0 is leaking somewhere (I did not want to run this down in the sources), I opted to perform short term connects, and that is working great. My application is for load testing, but I did not want to run tsung due to the Erlang dependency. I can run about 60 instances on a P4 cpu against the OPF 3.6.2 server, and has virtually no load (load average: 0.00, 0.00, 0.00). Each instances sends a message every 1.1 seconds, and disconnects/reconnects after 360 messages. MUC rooms 0 thru 49 are assumed to exist.

Thanks,

BEA

$ cat load.sh

#!/bin/sh -x

TARGET=XMPPLoadTester
FILE=uids.txt

file uids.txt

contains list of pairs of delimited uid,pwds, e.g.

“user_identifier_1”, “password_uid_1”

instances=60
pause_delay=13

mkfifo /tmp/load_test.fifo

java -server -cp .:smack.jar:smackx.jar $TARGET opf_svr.mysite.com $FILE $instances $pause_delay > /tmp/load_test.fifo

$ cat build.sh
#!/bin/sh -x

TARGET=XMPPLoadTester
#clean
rm -f *.class

#build

javac -d . $TARGET.java -cp …/smack_3_1_0/smack.jar:…/smack_3_1_0/smackx.jar

$ cat /tmp/load_test.fifo && ./load.sh

/* XMPPLoadTester.java */

import java.io.;
import java.lang.
;
import java.util.Date;
import org.jivesoftware.smack.;
import org.jivesoftware.smack.packet.
;
import org.jivesoftware.smackx.muc.;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.filter.
;

public class XMPPLoadTester implements Runnable {
String host;
String uid;
String pwd;
String chatroom;

public void run() {
try {
    while (true) {
    ConnectionConfiguration config = new ConnectionConfiguration(host, 5222);
    XMPPConnection conn1 = new XMPPConnection(config);

    conn1.connect();
    conn1.addPacketListener
        (
         new PacketListener() {
          public void processPacket(Packet packet) {
             System.out.println(packet.toXML());
         }
         },
         new PacketFilter() {
         public boolean accept(Packet packet) {
             return true;
         }
         }
         );

    conn1.login(uid, pwd);
    MultiUserChat chat = new MultiUserChat(conn1, chatroom + "@conference.mysite.com");
    chat.join(uid);
  
      for (int i = 0; i < 360; ++i) {
        String msg;
        Date now = new Date();;
        Double rand = new Double(Math.random());
        Integer ii = new Integer(i);

        msg = ii.toString() + ", " + now.toString() + ", " + rand.toString();
        chat.sendMessage(msg);
        Thread.sleep(1100);
    }
    conn1.disconnect();
  
      }
} catch (Exception e) { e.printStackTrace(); }
}

public static void main(String args[]) {
    // args[0] : host
    // args[1] = file uid/pwd pairs
    // args[2] = num of new instances
    // args[3] = delay between new instance

try {
    BufferedReader freader = new BufferedReader
    (new FileReader(args[1]));
    String line = null;
    int pause = Integer.parseInt(args[3]);
    int count = Integer.parseInt(args[2]);
    Thread th = null;

    for (int i = 0;
      i < count &&
          (line = freader.readLine()) != null;
      i++) {
    try {
        XMPPLoadTester xmppCli = new XMPPLoadTester();

        // initialize
        String tok[] = line.split("\", \"");
        xmppCli.host = args[0];
        xmppCli.uid  = tok[0].substring(1);
        xmppCli.pwd  = tok[1].substring(0,tok[1].length()-1);
        xmppCli.chatroom = (new Integer((i % 50))).toString();

        th = new Thread(xmppCli, xmppCli.uid);
        th.start();
        System.err.println("Started " + i + ", thread id " + th);
    } catch (Exception e) { e.printStackTrace(); }
    try {
        Thread.sleep(pause * 1000);
    } catch (Exception e) { e.printStackTrace(); }
    }
    freader.close();

    if (th != null) {
    System.err.println(th + "join");
    th.join();
    }
} catch (Exception e) { e.printStackTrace(); }
}

}

MUC chat room messages look like this:

(03:42:47 PM) jaadan: 336, Thu Jan 08 15:42:20 PST 2009, 0.7682591896412931
(03:42:47 PM) hennek: 173, Thu Jan 08 15:42:20 PST 2009, 0.6640701069067149
(03:42:48 PM) jaamdj: 190, Thu Jan 08 15:42:20 PST 2009, 0.5566031213247917
(03:42:48 PM) iaff27: 222, Thu Jan 08 09:20:09 PST 2009, 0.14924595131243856
(03:42:48 PM) henkwing: 307, Thu Jan 08 15:42:21 PST 2009, 0.061987698334588615

Hi…

I’ve been trying to use the Camel XMPP component which is based on Smack 3.0.4 and have run into similar memory issues. Has this been resolved with a post 3.1.0 release?

Thanks!

Good question, as far as what’s going into the commits, I do see activity, but nothing to address this specific issue.

http://www.igniterealtime.org/fisheye/viewrep/svn-org/spark

Also, this whole thread was in reference to a load testing exercise logged in http://www.igniterealtime.org/community/thread/36560

use this:

muc.nextMessage();

It worked for me.