[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

drb recycled object problem

Raj Sahae

3/26/2007 4:32:00 AM

I did a search on google and found the following page.
http://blade.nagaokaut.ac.jp/cgi-bin/vframe.rb/ruby/ruby-talk/13236?1...
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

16 Answers

Raj Sahae

3/26/2007 6:54:00 PM

0

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?1...
>
> 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

3/27/2007 1:37:00 AM

0

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?1...
>
> 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?

Ara.T.Howard

3/27/2007 1:52:00 AM

0

Raj Sahae

3/27/2007 3:16:00 AM

0

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?1...
>>> 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

Raj Sahae

3/27/2007 3:33:00 AM

0

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?1...
>>>> 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.

Ara.T.Howard

3/27/2007 5:00:00 AM

0

Raj Sahae

3/27/2007 11:40:00 AM

0

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)

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

Carlos

3/27/2007 12:05:00 PM

0

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?1...

Good luck.
--


Ara.T.Howard

3/27/2007 2:39:00 PM

0

Brian Candler

3/27/2007 6:37:00 PM

0

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