-
1. Re: Memory Leak with EJB3 ?
timfox Nov 9, 2006 11:29 AM (in response to mwelss)Transactions only get stored in the map on the server when your transaction manager is doing 2PC and they have been successfully prepared.
On commit or rollback they should be removed from the map.
The fact they are not being removed implies to me that you're transaction manager is not calling commit or rollback for some reason.
Can you enable trace logging on the server and look in the logs for the following strings? :created transaction commit process complete rollback process complete
If you're not expecting rollbacks then you should see the same or similar number of "created transaction" and "commit process complete".
Can you try this out?
Thanks. -
2. Re: Memory Leak with EJB3 ?
mwelss Nov 10, 2006 8:19 AM (in response to mwelss)We see the same number of creates and commits.
It is a EJB3 MDB which sends new messages and accesses the database in the onMessage() method. -
3. Re: Memory Leak with EJB3 ?
timfox Nov 10, 2006 8:29 AM (in response to mwelss)That's strange.
The only place in the code that a tx is added to the map is in the create, and it's only removed in two places - commit or rollback.
Can you replicate this is in a test case and send to me? thanks. -
-
5. Re: Memory Leak with EJB3 ?
dunks80 Jan 26, 2007 1:42 PM (in response to mwelss)JBoss 4.0.5.GA
JBoss Messaging 1.0.1
Jboss TS 4.2.2
MS-SQL 2000 w/jtds driver
I'm seeing the same problem. Tenured gen is filling up with org.jboss.jms.tx.TxState and org.jboss.jms.tx.LocalTx when processing messages using an EJB3 MDB. I am debugging through the org.jboss.jms.tx.MessagingXAResource and here is what I'm seeing...
Inpublic void start(Xid xid, int flags) throws XAException
A new TxState is put into the ResourceManager's map of transactions.
Inpublic void end(Xid xid, int flags) throws XAException
Another new TxState is put into the map of transactions b/c of the call to unsetCurrentTransactionId.// Don't unset the xid if it has previously been suspended. The session could have been // recycled if (xid.equals(sessionState.getCurrentTxId())) { sessionState.setCurrentTxId(rm.createLocalTx()); }
which is called no matter what the outcome of the transaction based on this code...public void end(Xid xid, int flags) throws XAException { if (trace) { log.trace(this + " ending " + xid + ", flags: " + flags); } synchronized (this) { switch (flags) { case TMSUSPEND : unsetCurrentTransactionId(xid); rm.suspendTx(xid); break; case TMFAIL : unsetCurrentTransactionId(xid); rm.endTx(xid, false); break; case TMSUCCESS : unsetCurrentTransactionId(xid); rm.endTx(xid, true); break; } } }
I'm not by any means an expert in the TX code...but this unsetCurrentTransactionId seems to be what's causing the problem...the xid is always equal to the currentTxId so a new TxState is added to the ResourceManager's map of transactions. Is this correct? Why? This results in two TxState objects being put into the transaction map for each transaction...and only one gets removed when commit is called...causing the heap to grow.
Inpublic void commit(Xid xid, boolean onePhase) throws XAException
the first TxState is removed from the map of transactions.
Is there something I've done wrong to cause this behavior? TransactionAttribute settings? Some setting in JBoss Messaging? Of is this a genuine bug? -
6. Re: Memory Leak with EJB3 ?
timfox Jan 26, 2007 3:04 PM (in response to mwelss)Looks like it could be a bug.
We're massively rushed off our feet right now, but could you add a bug report in JIRA, and I'll take a deeper look at it ASAP?
Thanks. -
7. Re: Memory Leak with EJB3 ?
dunks80 Jan 26, 2007 3:29 PM (in response to mwelss)Are you sure I should create a new issues? This doesn't fall under http://jira.jboss.com/jira/browse/JBMESSAGING-638? If not I'll be happy to create a new one.
-
8. Re: Memory Leak with EJB3 ?
timfox Jan 26, 2007 3:33 PM (in response to mwelss)Sorry, you're quite right.
Could you add a comment to the existing issue on you're explanation for the leak, and link to this thread?
Thanks :) -
9. Re: Memory Leak with EJB3 ?
timfox Jan 26, 2007 5:51 PM (in response to mwelss)I have replicated this problem in a couple of test cases.
The fix should be pretty straightforward.
We are putting out a service pack for 1.0.1 (SP4) probably some time next week. I will make sure it gets into that. -
10. Re: Memory Leak with EJB3 ?
timfox Feb 1, 2007 6:20 PM (in response to mwelss)Fixed in TRUNK
http://jira.jboss.com/jira/browse/JBMESSAGING-638 -
11. Re: Memory Leak with EJB3 ?
timfox Feb 2, 2007 1:07 PM (in response to mwelss)And will soon be in SP4