-->
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.  [ 2 posts ] 
Author Message
 Post subject: Paging out loaded objects (reverse lazy loading)
PostPosted: Thu Aug 03, 2006 11:17 am 
Newbie

Joined: Tue Aug 01, 2006 12:42 pm
Posts: 11
I haven't been able to track down whether Hibernate supports the reverse of lazy loading. Can anyone out there let me know whether anything like this exists in Hibernate?

What I mean is, if I have an object in memory (say, it's been lazy loaded) and I decide I want to replace that real object with a proxy (ie. page it out). On subsequent reference, lazy loading will just page it back in.

ISession.evict() doesn't seem to do the trick because it doesn't actually remove the object from memory.

This can be very useful for objects with large memory footprints (using an LRU algorithm).

Many thanks to all!


Top
 Profile  
 
 Post subject: Paging out loaded objects (don't think so)
PostPosted: Thu Aug 03, 2006 12:05 pm 
Newbie

Joined: Thu Aug 03, 2006 11:40 am
Posts: 4
hi e.d.,

i assume you're using java (not NHibernate)? there is no conventional way to "remove an object from memory" in java -- the best you can do is null out your references to the object and wait for the garbage collector to take care of it when necessary and/or opportune to do so. if the object is fairly large, was recently created, and is completely unreferenced, it is likely to be collected quickly.

if you aren't using java, you can probably disregard the rest of this post :).

in any case, i don't think there is any way to accomplish this currently in Hibernate. it's a neat idea, though.

the problem is that hibernate isn't aware of where there might be other references to the object in memory. the best you could do is provide an alternate Session implementation that only maintains weak references to objects in Session (a weak reference means that the garbage collector is allowed to remove the referenced object from memory if necessary). this would be a *substantial* development effort.

an alternate architecture for controlling memory in hibernate involves using the object cache effectively. tune the cache to store frequently used objects at the VM level, and then keep your hibernate session lifespan relatively short (e.g. one per servlet requests) to keep objects only occasionally used out of residence. this is kind of a complementary strategy to yours -- "only save the objects that i want to keep" instead of "get rid of the objects i don't need"

jt


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.