-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Preventing OutOfMemoryError once and for all
PostPosted: Fri Jan 18, 2008 2:44 pm 
Newbie

Joined: Fri Jan 18, 2008 2:32 pm
Posts: 8
Greetings,

I'm going to have to write a lot of modules that fetch a possibly large amount of objects using hibernate. Instead of using conventional methods such as limiting the number of fetched objects in each query (which would probably not be optimal because different objects may be with different sizes and also I would have to to many tests to find the limit for each query before OOME), I would like to somehow tell Hibernate that while fetching and building the returned collection to check the amount of memory that the collection occupies and if it is above a certain amount to stop or throw an exception or do anything recoverable. Does anyone have an idea how to to this?

Thanks.

_________________
Gabriel Axel
http://www.gabiaxel.com/


Top
 Profile  
 
 Post subject: Re: Preventing OutOfMemoryError once and for all
PostPosted: Fri Jan 18, 2008 4:37 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
I am wondering if you could do anything with either interceptors or events. you can examine an object for its collection size and throw an exception if you like. However, I have never used either events or interceptors and I can not tell you which method might be the best place to catch this.


Farzad-


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 18, 2008 5:49 pm 
Newbie

Joined: Fri Oct 12, 2007 5:51 pm
Posts: 5
Couldn't you iterate over all the results from a ScrollableResults instead of keeping all elements in memory?
You can create an iterator that wraps around a ScrollableResults and iterates over 'live' data.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.