Oct 31st, 2005, 05:08 AM
openSessionInViewInterceptor and Java heap space
I am building web application (blogs, pictures...). I am using openSessionInViewInterceptor. It works fine but when I try to display member's page i get exception: Java heap space. All connections are set to lazy="true". Seems to me, that all member's connections (blog, gallery, messages, comments) are loaded to memory. Am I right? Do You have any solution for that?
Oct 31st, 2005, 08:59 AM
Sounds like you are running out of memory. Since you are using one session, hiberante will cache each object in that one session. If you are loading a massive amount of data, you could run out of memory. The solution is to call clear on the hibernate session.
Nov 1st, 2005, 11:40 AM
Do You know, how to do this in openSessionInViewInterceptor?
Nov 2nd, 2005, 12:53 AM
You can't do it in the interceptor directory. I recommend you evict your objects from the session immediately following the processing of those objects. This means doing it inside your DAO, for instance (or whereever you have access to the session).
If you are doing a mass update, consider bypassing hibernate, and executing one single UPDATE into the DB.