Mark Spritzler wrote:Well, you can consider the Heap space. So for every object you load, it takes up heap space. If you load more and more, garbage collection comes into play as well as the sizing of the heap space.
You can try to increase it with -Xmx and -Xms to see if that helps.
Also do you need to load all those users, or can you do some batch, and pagination logic to not load 5000 objects at once into the Session.
Let us know how that goes.
Mark
Thanks for your response Mark. I got your point but I want to know there are are several methods in application which are showing consistent behavior only this method more precisely only that particular line of code is creating problem whereas I have now save the multiple database hits also by implementing second level cache. Also I didn't understood about paginataion logic I am using aop:config in my application where the transaction commits after the execution of all methods.