users@glassfish.java.net

Re: TopLink Essentials cannot handle large transactions, makes JVM run out of memory.

From: <glassfish_at_javadesktop.org>
Date: Tue, 11 Sep 2007 12:29:16 PDT

The issue is that TopLink has a shared cache that it wants to merge the changes for the transaction into. TopLink cannot merge into the shared cache until the final commit of the transaction, so all the object changes are held in memory until the final commit. Technically we should through away the changes on a clear(), so please log a bug for this.

As a workaround you can create a separate transaction for each batch of objects, instead of processing them all in a single transaction. This will also be much more efficient on the database.

If you cannot do this, you could potentially work around the issue by going under the covers in TopLink and calling beginTransaction() and commitTransaction() on the TopLink EntityManager AbstractSession, then using a seperate JPA Transaction begin()/commit() for each batch, TopLink will hold the transaction open until the finally commitTransaction(). (but this is somewhat advanced).

---
<a href="http://wiki.java.net/bin/view/People/JamesSutherland">James Sutherland</a>
[Message sent by forum member 'james_sutherland' (james_sutherland)]
http://forums.java.net/jive/thread.jspa?messageID=234912