[email protected]
[Top] [All Lists]

getIteratorByQuery + thousands of objects = OutOfMemoryError

Subject: getIteratorByQuery + thousands of objects = OutOfMemoryError
From: "Vasily Ivanov"
Date: Fri, 16 Nov 2007 19:26:13 +1100

We've got a system that needs to update thousands (possibly hundreds
of thousands) of Objects.

After reading OJB FAQ I thought that
PersistenceBroker.getIteratorByQuery(query) would be the best solution
in this case. Query runs fine and returns RsIterator. However the
problems start when I try to iterate and process few thousands of
records eventually I get OutOfMemoryError (out of java heap). I did
profiling and found that QueryReferenceBroker object holds a big
ArrayList called prefetchingListeners that grows rapidly while
iterating. I think that's because OJB keeps all objects to commit when
PersistenceBroker is closed.

What I do is I call the following statement after each iteration:

That helped but that's obviously not the best way of doing it and I
don't know how thread-safe it is.

Is there any more appropriate way of doing that?

Thank you,

To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

<Prev in Thread] Current Thread [Next in Thread>