Openfire leaking threads

Hi

I was running a tsung performance test on openfire. It first worked fine, but then started leaking threads. Openfire created quite fast hundreds of threads. I made a thread dump and there is a huge amount of “PEP service maintenance” threads.

Here is a sample of 2 from the dump:

“PEP service maintenance” daemon prio=10 tid=0x00002ab226b8b000 nid=0x29c0 in Object.wait() [0x00002ab22a70c000…0x00002ab22a70cc90]
java.lang.Thread.State: TIMED_WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
at java.util.TimerThread.mainLoop(Unknown Source)
- locked <0x00002aaf6bf7eae0> (a java.util.TaskQueue)
at java.util.TimerThread.run(Unknown Source)

“PEP service maintenance” daemon prio=10 tid=0x00002ab226b89000 nid=0x29bf in Object.wait() [0x00002ab22a60b000…0x00002ab22a60bb10]
java.lang.Thread.State: TIMED_WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
at java.util.TimerThread.mainLoop(Unknown Source)
- locked <0x00002aaf6bef13f8> (a java.util.TaskQueue)
at java.util.TimerThread.run(Unknown Source)

I quickly browsed the codes and found a potential bug:

PEPService class has instance variable Timer:

row 133 in PEPService: * private Timer timer = new Timer(“PEP service maintenance”);*

Timer javadoc says: “Corresponding to each Timer object is a single background thread…” == timer = thread

IQPEPHandler class creates an instance of PEPService per JID from the message came:

*// If no service exists yet for jidFrom, create one.
if (pepService == null) {
*

  • ----- clip---
    
  •                pepService = new PEPService(XMPPServer.getInstance(), jidFrom);
                  pepServices.put(jidFrom, pepService);*
    

Sounds like a design bug? (or a nasty feature )

  • Matti

Thanks for the bug report. I filed this as http://www.igniterealtime.org/issues/browse/JM-1493 and checked in a fix for 3.6.1.

– Gato

Thank you Gaston, that was fast fix!

  • Matti