Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > DRb cleaning up client objects created by clients

Reply
Thread Tools

DRb cleaning up client objects created by clients

 
 
Aaron Turner
Guest
Posts: n/a
 
      01-24-2008
Hopefully the below makes sense...

My DRb server's front object has a method called 'create_foo' which
creates & returns a new instance of class Foo. The Foo class must
keep track of the number of active Foo objects and enforces a limit.
Well behaved clients call my_foo_obj.free before releasing their
reference to my_foo_obj which updates the Foo class tracker. Of
course, not all clients are well behaved (they crash, user CTRL-C's
them, server they're on get rebooted, etc). The result is that stale
objects stay around indefinitely and are never marked as released in
the Foo class. Foo class leaks objects and ends up stoping creating
new ones.

I've tried creating a Foo.finalizer method which does the free(), but
that doesn't work, even when I force garbage collection. Both the
front object and Foo class are DRbUndumped.

Anyways, it would be great if there was a way for the DRb server to
detect a client has disconnected and react accordingly, but I can't
find any way to hook into the DRb class to do that. Suggestions?

--
Aaron Turner
http://synfin.net/
http://tcpreplay.synfin.net/ - Pcap editing & replay tools for Unix
They that can give up essential liberty to obtain a little temporary
safety deserve neither liberty nor safety. -- Benjamin Franklin

 
Reply With Quote
 
 
 
 
Marcin Raczkowski
Guest
Posts: n/a
 
      01-24-2008
Aaron Turner wrote:
> Hopefully the below makes sense...
>
> My DRb server's front object has a method called 'create_foo' which
> creates & returns a new instance of class Foo. The Foo class must
> keep track of the number of active Foo objects and enforces a limit.
> Well behaved clients call my_foo_obj.free before releasing their
> reference to my_foo_obj which updates the Foo class tracker. Of
> course, not all clients are well behaved (they crash, user CTRL-C's
> them, server they're on get rebooted, etc). The result is that stale
> objects stay around indefinitely and are never marked as released in
> the Foo class. Foo class leaks objects and ends up stoping creating
> new ones.
>
> I've tried creating a Foo.finalizer method which does the free(), but
> that doesn't work, even when I force garbage collection. Both the
> front object and Foo class are DRbUndumped.
>
> Anyways, it would be great if there was a way for the DRb server to
> detect a client has disconnected and react accordingly, but I can't
> find any way to hook into the DRb class to do that. Suggestions?
>


It's problem with both GC and DRb.

finilizer will never be run becouse it's run just before object is
collected - since DRb is not releasing reference it's newer collected.

try using object proxy (delegator)

 
Reply With Quote
 
 
 
 
Aaron Turner
Guest
Posts: n/a
 
      01-24-2008
On Jan 23, 2008 9:48 PM, Marcin Raczkowski <> wrote:
>
> It's problem with both GC and DRb.
>
> finilizer will never be run becouse it's run just before object is
> collected - since DRb is not releasing reference it's newer collected.


That tends to agree with my research

> try using object proxy (delegator)


Sorry not familiar with the module, concept or whatever you're
referring to. Link?

Thanks,
Aaron

--
Aaron Turner
http://synfin.net/
http://tcpreplay.synfin.net/ - Pcap editing & replay tools for Unix
They that can give up essential liberty to obtain a little temporary
safety deserve neither liberty nor safety. -- Benjamin Franklin

 
Reply With Quote
 
Marcin Raczkowski
Guest
Posts: n/a
 
      01-24-2008
Aaron Turner wrote:
> On Jan 23, 2008 9:48 PM, Marcin Raczkowski <> wrote:
>> It's problem with both GC and DRb.
>>
>> finilizer will never be run becouse it's run just before object is
>> collected - since DRb is not releasing reference it's newer collected.

>
> That tends to agree with my research
>
>> try using object proxy (delegator)

>
> Sorry not familiar with the module, concept or whatever you're
> referring to. Link?
>
> Thanks,
> Aaron
>


On server side you define empty object that ovverwrites method_missing
and every call is transported to coresponding "real" object.

It's ugly hack, becouse proxy objects will never be collected unless
issue is fixed in DRb, but that should help with memory usage (almost
empty objects should not be really memory consuming)

and you can menage all the references server side.

If you are looking for better solution check packet and EventMachine,
BackgroundRB recently switched to Packet becouse of DRb issues.

cheers


 
Reply With Quote
 
ara.t.howard
Guest
Posts: n/a
 
      01-24-2008

On Jan 23, 2008, at 10:12 PM, Aaron Turner wrote:

>
> My DRb server's front object has a method called 'create_foo' which
> creates & returns a new instance of class Foo. The Foo class must
> keep track of the number of active Foo objects and enforces a limit.
> Well behaved clients call my_foo_obj.free before releasing their
> reference to my_foo_obj which updates the Foo class tracker. Of
> course, not all clients are well behaved (they crash, user CTRL-C's
> them, server they're on get rebooted, etc). The result is that stale
> objects stay around indefinitely and are never marked as released in
> the Foo class. Foo class leaks objects and ends up stoping creating
> new ones.


- use DRbUndumped to keep Foos on the server

- store all active Foos in a list

- provide a callback to the client when constructing the Foos,
possibly just a block passed to the method (since invocation of it
would run on the client)

- whenever a new Foos is requested sweep the list invoking the
callbacks/blocks. if the client has evaporated this will throw -
nuke the Foo from the list

a @ http://codeforpeople.com/
--
it is not enough to be compassionate. you must act.
h.h. the 14th dalai lama




 
Reply With Quote
 
Marcin Raczkowski
Guest
Posts: n/a
 
      01-24-2008
>
> - use DRbUndumped to keep Foos on the server

he mentioned that he's using that already



 
Reply With Quote
 
Aaron Turner
Guest
Posts: n/a
 
      01-24-2008
On Jan 24, 2008 12:33 AM, ara.t.howard <> wrote:
> - use DRbUndumped to keep Foos on the server
>
> - store all active Foos in a list
>
> - provide a callback to the client when constructing the Foos,
> possibly just a block passed to the method (since invocation of it
> would run on the client)
>
> - whenever a new Foos is requested sweep the list invoking the
> callbacks/blocks. if the client has evaporated this will throw -
> nuke the Foo from the list


Ah, yes, that should meet my needs. Thanks to everyone else who
responded with ideas.

--
Aaron Turner
http://synfin.net/
http://tcpreplay.synfin.net/ - Pcap editing & replay tools for Unix
They that can give up essential liberty to obtain a little temporary
safety deserve neither liberty nor safety. -- Benjamin Franklin

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DRB: can't run subshell in drb server? Ittay Dror Ruby 1 10-21-2008 11:28 AM
DRb connection error with more than 250+ DRb services J. Wook Ruby 16 05-16-2007 11:32 AM
More DRb; SSL & DRB & errors Kirk Haines Ruby 0 07-01-2005 06:29 PM
are the objects created in the stack guarranted to have been created? jimjim C++ 12 06-03-2005 12:57 PM
DRb / dRuby - freezes on DRb::DRbUndumped - any ideas? Miles Keaton Ruby 3 03-30-2005 03:37 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57