when analysing heap dump with eclipse MAT - it shows
org.hibernate.engine.internal.StatefulPersistenceContext @ 0x7162d8da8 shows shallow heap 104 and retained heap 1404448424
seems to be biggest memory is consumed here
our way of calling hibernte is
Code:
return (Collection) getHibernateTemplate().execute(new HibernateCallback()
{
public Object doInHibernate(Session session) throws HibernateException
{
return getResultFromQuery(session, queryStr, fetchSize, nextRecord, parameterNames, parameters);
}
});
private Object getResultFromQuery(Session session,
String queryStr,
int fetchSize,
int nextRecord,
String[] parameterNames, Object[] parameters)
{
Query query = session.createQuery(queryStr);
if (fetchSize != -1)
{
query.setFirstResult(nextRecord);
query.setMaxResults(fetchSize);
}
for (int i = 0; i < parameterNames.length; i++)
{
String name = parameterNames[i];
query.setParameter(name, parameters[i]);
}
List list = query.list();
if (notSupportDistinct)
{
return new LinkedHashSet(list);
}
return list;
}
the out of memory stacktrace is pointing to where we get list value
Code:
List list = query.list();
what are we doing wrong ?
how can memory usage be reduced ?