Memory management

I am new to Ruby. If I instantiate an object instance with

x = Foo.new

should I set x to nil to free the object instance when it is no longer
needed?

Can anyone point me to any articles etc. on memory management in Ruby?

Thanks.

If you set x to nil, the garbage collector can free the memory because
there is not a reference to this area.

Bazsl wrote:

For the most part you don’t need to worry about memory management in
Ruby. When there are no more references to an object, Ruby’s garbage
collector will collect the object and make its storage available for
re-use.

If you want to know more, here’s a good article:
http://whytheluckystiff.net/articles/theFullyUpturnedBin.html.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs