Out of Memory When Loading Java Entities
- by Hugh Buchanan
I have a terrible problem that hopefully has a very simple answer. I am running out of memory when I perform a basic
If I have code like this:
MyEntity myEntity;
for (Object id: someIdList) {
myEntity = find(id);
// do something basic with myEntity
}
And the find() method is a standard EntityManager related method:
public MyEntity find(Object id) {
return em.find(mycorp.ejb.entity.MyEntity.class, id);
}
This code worked a couple of weeks ago, and works fine if there are fewer items in the database. The resulting error I am facing is:
java.lang.OutOfMemoryError: GC overhead limit exceeded
The exception is coming from oracle toplink calling some oracle jdbc methods.
The loop exists because an EJBQL such as "select object(o) from MyEntity as o" will overload the application server when there are lots of records.