Drb recycled object problem

I did a search on google and found the following page.
http://blade.nagaokaut.ac.jp/cgi-bin/vframe.rb/ruby/ruby-talk/13236?13221-13721
Going down on that page, you find a header saying 'drb and "recycled objects" error'.
I am having a similar error (recycled object, RangeError), but I don't understand the solution given here, and I was hoping someone could explain to me what the solution is, and why it works. What is GCing?

Raj Sahae

Raj Sahae wrote:

I did a search on google and found the following page.
http://blade.nagaokaut.ac.jp/cgi-bin/vframe.rb/ruby/ruby-talk/13236?13221-13721

Going down on that page, you find a header saying 'drb and "recycled objects" error'.
I am having a similar error (recycled object, RangeError), but I don't understand the solution given here, and I was hoping someone could explain to me what the solution is, and why it works. What is GCing?

Raj Sahae

As an addendum, I ran this guys test code on my comp and I didn't get any of his problems. So what causes the recycled object error now, assuming the earlier problem was fixed?

Raj

Raj Sahae wrote:

I did a search on google and found the following page.
http://blade.nagaokaut.ac.jp/cgi-bin/vframe.rb/ruby/ruby-talk/13236?13221-13721

Going down on that page, you find a header saying 'drb and "recycled objects" error'.
I am having a similar error (recycled object, RangeError), but I don't understand the solution given here, and I was hoping someone could explain to me what the solution is, and why it works. What is GCing?

Raj Sahae

bump?

you have a handle on an object which has been garbage collected on the server.
if you're going to be serving objects you need to be sure a reference to them
   is maintained on the server.

-a

···

On Tue, 27 Mar 2007, Raj Sahae wrote:

Raj Sahae wrote:

I did a search on google and found the following page.
http://blade.nagaokaut.ac.jp/cgi-bin/vframe.rb/ruby/ruby-talk/13236?13221-13721 Going down on that page, you find a header saying 'drb and "recycled objects" error'.
I am having a similar error (recycled object, RangeError), but I don't understand the solution given here, and I was hoping someone could explain to me what the solution is, and why it works. What is GCing?

Raj Sahae

bump?

--
be kind whenever possible... it is always possible.
- the dalai lama

Ahh, that's what recycled object means then. So how do I prevent the object from being recycled until the server program is exited. Also, why is the server recycling an object that is still in use?

Raj

···

ara.t.howard@noaa.gov wrote:

On Tue, 27 Mar 2007, Raj Sahae wrote:

Raj Sahae wrote:

I did a search on google and found the following page.
http://blade.nagaokaut.ac.jp/cgi-bin/vframe.rb/ruby/ruby-talk/13236?13221-13721 Going down on that page, you find a header saying 'drb and "recycled objects" error'.
I am having a similar error (recycled object, RangeError), but I don't understand the solution given here, and I was hoping someone could explain to me what the solution is, and why it works. What is GCing?

Raj Sahae

bump?

you have a handle on an object which has been garbage collected on the server.
if you're going to be serving objects you need to be sure a reference to them
  is maintained on the server.

-a

Raj Sahae wrote:

···

ara.t.howard@noaa.gov wrote:

On Tue, 27 Mar 2007, Raj Sahae wrote:

Raj Sahae wrote:

I did a search on google and found the following page.
http://blade.nagaokaut.ac.jp/cgi-bin/vframe.rb/ruby/ruby-talk/13236?13221-13721 Going down on that page, you find a header saying 'drb and "recycled objects" error'.
I am having a similar error (recycled object, RangeError), but I don't understand the solution given here, and I was hoping someone could explain to me what the solution is, and why it works. What is GCing?

Raj Sahae

bump?

you have a handle on an object which has been garbage collected on the server.
if you're going to be serving objects you need to be sure a reference to them
  is maintained on the server.

-a

Ahh, that's what recycled object means then. So how do I prevent the object from being recycled until the server program is exited. Also, why is the server recycling an object that is still in use?

Raj

Sorry for the double post. I should have done a little reading on the GC module before asking that last question. Let me rephrase and instead ask, is it wise to disable garbage collection at the beginning of a program, then enable it when the program quits out? Seems to me that's asking for trouble unless you really know what you are doing.

Raj Sahae wrote:
[...]

···

ara.t.howard@noaa.gov wrote:

you have a handle on an object which has been garbage collected on the server.
if you're going to be serving objects you need to be sure a reference to them
  is maintained on the server.

-a

Ahh, that's what recycled object means then. So how do I prevent the object from being recycled until the server program is exited. Also, why is the server recycling an object that is still in use?

Doesn't this message in the thread you mentioned help you?

http://blade.nagaokaut.ac.jp/cgi-bin/vframe.rb/ruby/ruby-talk/13293?13221-13721

Good luck.
--

yeah. terrible idea.

you just need to keep a reference to it to prevent it from being gc'd. can
you show use some code?

-a

···

On Tue, 27 Mar 2007, Raj Sahae wrote:

Ahh, that's what recycled object means then. So how do I prevent the object from being recycled until the server program is exited. Also, why is the server recycling an object that is still in use?

Raj

Sorry for the double post. I should have done a little reading on the GC module before asking that last question. Let me rephrase and instead ask, is it wise to disable garbage collection at the beginning of a program, then enable it when the program quits out? Seems to me that's asking for trouble unless you really know what you are doing.

--
be kind whenever possible... it is always possible.
- the dalai lama

Snipping code would be tricky. It's a fairly large program. None of the objects that are important are ever, EVER, not referenced somehow. Everything is stored in arrays, and transferred around in arrays. Objects on the server are moved from array to array by the client calling methods using DRb. What kind of code would you want me to show you to prove this?

# on the server
DRb.start_service($uri, server.game)

# on the client
DRb.start_service
game = DRbObject.new(nil, "druby://#{ipfield.text}:#{$port}") #
File.open($deck_dir + filefield.text.strip, "r"){|file| game.add_player(namefield.text, file.gets)}

then the client operates by making repeated method calls on "game"

···

ara.t.howard@noaa.gov wrote:

yeah. terrible idea.

you just need to keep a reference to it to prevent it from being gc'd. can
you show use some code?

-a

yeah. terrible idea.

you just need to keep a reference to it to prevent it from being gc'd. can
you show use some code?

-a

Snipping code would be tricky. It's a fairly large program. None of the objects that are important are ever, EVER, not referenced somehow.

but the error is telling you that this is exactly what's happening?

Everything is stored in arrays, and transferred around in arrays. Objects
on the server are moved from array to array by the client calling methods
using DRb. What kind of code would you want me to show you to prove this?

it's like this; there are two possibilities:

   1) you've found a bug in ruby and/or drb

   2) you are not actually keeping a reference on every object the client gets
   a remote reference on and some object(s) is being collected

given that drb is heavily used and mature it's probably wise to spend time
tracking down #2. if you're going to look into #2 there is probably help on
this list. basically you need to figure out which object is being lost and
track its lifecycle on the server.

regards.

-a

···

On Tue, 27 Mar 2007, Raj Sahae wrote:

ara.t.howard@noaa.gov wrote:

--
be kind whenever possible... it is always possible.
- the dalai lama

$foo = server.game
DRb.start_service($uri, $foo)

Keeping a reference to the object in global variable $foo is one way to stop
it frm being garbage collected.

A local variable is fine, as long as it doesn't drop out of scope: e.g.

foo = server.game
DRb.start_service($uri, foo)
DRb.thread.join # program waits here

···

On Tue, Mar 27, 2007 at 08:39:36PM +0900, Raj Sahae wrote:

ara.t.howard@noaa.gov wrote:
>yeah. terrible idea.
>
>you just need to keep a reference to it to prevent it from being
>gc'd. can
>you show use some code?
>
>-a
Snipping code would be tricky. It's a fairly large program. None of
the objects that are important are ever, EVER, not referenced somehow.
Everything is stored in arrays, and transferred around in arrays.
Objects on the server are moved from array to array by the client
calling methods using DRb. What kind of code would you want me to show
you to prove this?

# on the server
DRb.start_service($uri, server.game)

drb itself holds a referent to this, the 'front', object - so i don't think
that'll help too much. i'm guessing the game returns result objects of some
type which are recycled in the server while the client tries to re-use them.

cheers.

-a

···

On Wed, 28 Mar 2007, Brian Candler wrote:

On Tue, Mar 27, 2007 at 08:39:36PM +0900, Raj Sahae wrote:

ara.t.howard@noaa.gov wrote:

yeah. terrible idea.

you just need to keep a reference to it to prevent it from being
gc'd. can
you show use some code?

-a

Snipping code would be tricky. It's a fairly large program. None of
the objects that are important are ever, EVER, not referenced somehow.
Everything is stored in arrays, and transferred around in arrays.
Objects on the server are moved from array to array by the client
calling methods using DRb. What kind of code would you want me to show
you to prove this?

# on the server
DRb.start_service($uri, server.game)

$foo = server.game
DRb.start_service($uri, $foo)

Keeping a reference to the object in global variable $foo is one way to stop
it frm being garbage collected.

A local variable is fine, as long as it doesn't drop out of scope: e.g.

foo = server.game
DRb.start_service($uri, foo)
DRb.thread.join # program waits here

--
be kind whenever possible... it is always possible.
- the dalai lama

Thanks guys. I'll keep these tips in mind while I keep digging through my code, trying to find if I let go of a reference somewhere.

Raj

···

ara.t.howard@noaa.gov wrote:

On Wed, 28 Mar 2007, Brian Candler wrote:

$foo = server.game
DRb.start_service($uri, $foo)

Keeping a reference to the object in global variable $foo is one way to stop
it frm being garbage collected.

A local variable is fine, as long as it doesn't drop out of scope: e.g.

foo = server.game
DRb.start_service($uri, foo)
DRb.thread.join # program waits here

drb itself holds a referent to this, the 'front', object - so i don't think
that'll help too much. i'm guessing the game returns result objects of some
type which are recycled in the server while the client tries to re-use them.

cheers.

-a