-----Messaggio originale-----
Da: Robert Klemme [mailto:shortcutter / googlemail.com] 
Inviato: marted27 dicembre 2011 11:57
A: ruby-talk ML
Oggetto: Re: Free an Object

On Mon, Dec 26, 2011 at 9:18 PM, Tridib Bandopadhyay <tridib04 / gmail.com>
wrote:
> I have made an extension of my own which will help the user to 
> manually allocate and deallocate an object using a ruby program in a 
> stack which my extension file is handling, and my extension does work
properly.

Apparently not because:

> Now I debugged some code in gc.c file and came to the point that 
> Garbage Collector is also marking that same object and hopefully 
> allocating also(which I am not sure) as a result there will duplicate 
> objects in the memory.To check this I asked for when the garbage 
> collector is freeing the memory.Is there any other way I can check if 
> the garbage collector is storing the object in the memory or not?

I do not know the code but apparently you have managed to mix up Ruby's
allocation with your own.  It seems you want to build an optimization by
placing some objects on the stack.  However, you need to be aware that this
approach will fail the very moment that you pass a reference of your stack
stored object to another object which resides on the heap (i.e _not_ on the
stack).

> Also, I have some few questions also-
>
> 1. Why some methods/Functions inside some file starts with the name--
>
> rb_alloc()... what does the "rb" in the method name means?

"rb" means "Ruby".  This is the C version of a namespace.

> 2. Is there any way to stop the ruby program in the middle of 
> execution?. Like sleep type of function

Sleeping is not exactly stopping.  If you work with a C debugger you only
need to set a breakpoint at the proper location.

Cheers

robert

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/


 
 
 --
 Caselle da 1GB, trasmetti allegati fino a 3GB e in piu' IMAP, POP3 e SMTP autenticato? GRATIS solo con Email.it http://www.email.it/f
 
 Sponsor:
 Riccione Hotel 3 stelle in centro: Pacchetto Capodanno mezza pensione, animazione bimbi, zona relax, parcheggio. Scopri l'offerta solo per oggi...
 Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid983&d)-12