Friday, 7 September 2012

memory management in ruby

In Ruby memory management is done by Garbage collector. In Ruby every thing is stored in heap memory. So in ruby memory allocation and freezing of memory will be done automatically.




As ruby is dynamic datatype, the default datatype will be taken as string and once the value was assigned to variable, depending on the datatype the memory will be allocated and remaining memory will be deleted in the heap. So it is not required to release the allocated memory by programmer as every thing will be taken care by the garbage collector.

Below is the URL, you can view the clear explanation of how the memory allocation and how garbage collector freed memory is ruby,

URL: http://patshaughnessy.net/2012/3/23/why-you-should-be-excited-about-garbage-collection-in-ruby-2-0

Question:
Q) Does ruby uses stack for memory allocation?
A) Here is the complete explanation of how memory management takes places was explained clearly on bases of ruby version wise.
URL: http://www.engineyard.com/blog/2010/mri-memory-allocation-a-primer-for-developers/

Thank You,
Uma Mahesh.

No comments:

Post a Comment