drb recycled object problem

R

Raj Sahae

Raj said:
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
 
R

Raj Sahae

A

ara.t.howard


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
 
R

Raj Sahae

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
 
R

Raj Sahae

Raj said:
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.
 
A

ara.t.howard

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.

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
 
R

Raj Sahae

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)

# 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"
 
A

ara.t.howard

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
 
B

Brian Candler

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
 
A

ara.t.howard

$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
 
R

Raj Sahae

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
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top