<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: MRI Memory Allocation, A Primer For Developers</title>
	<atom:link href="http://www.engineyard.com/blog/2010/mri-memory-allocation-a-primer-for-developers/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.engineyard.com/blog/2010/mri-memory-allocation-a-primer-for-developers/</link>
	<description></description>
	<lastBuildDate>Wed, 08 Feb 2012 12:12:12 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: alpinestars boots</title>
		<link>http://www.engineyard.com/blog/2010/mri-memory-allocation-a-primer-for-developers/comment-page-1/#comment-59232</link>
		<dc:creator>alpinestars boots</dc:creator>
		<pubDate>Thu, 01 Dec 2011 01:41:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.engineyard.com/blog/?p=3647#comment-59232</guid>
		<description>you need to have a basic understanding of what’s going on with memory management in the interpreter.</description>
		<content:encoded><![CDATA[<p>you need to have a basic understanding of what’s going on with memory management in the interpreter.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nike superfly cleats</title>
		<link>http://www.engineyard.com/blog/2010/mri-memory-allocation-a-primer-for-developers/comment-page-1/#comment-58909</link>
		<dc:creator>nike superfly cleats</dc:creator>
		<pubDate>Tue, 06 Sep 2011 09:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.engineyard.com/blog/?p=3647#comment-58909</guid>
		<description>it   is  industrious   blog   !</description>
		<content:encoded><![CDATA[<p>it   is  industrious   blog   !</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: wholesale mac cosmetics</title>
		<link>http://www.engineyard.com/blog/2010/mri-memory-allocation-a-primer-for-developers/comment-page-1/#comment-58898</link>
		<dc:creator>wholesale mac cosmetics</dc:creator>
		<pubDate>Wed, 31 Aug 2011 08:32:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.engineyard.com/blog/?p=3647#comment-58898</guid>
		<description>a developer who remains ignorant of what’s going on under the covers does so at his or her own peril</description>
		<content:encoded><![CDATA[<p>a developer who remains ignorant of what’s going on under the covers does so at his or her own peril</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nike mercurial safari</title>
		<link>http://www.engineyard.com/blog/2010/mri-memory-allocation-a-primer-for-developers/comment-page-1/#comment-58869</link>
		<dc:creator>nike mercurial safari</dc:creator>
		<pubDate>Sat, 27 Aug 2011 07:44:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.engineyard.com/blog/?p=3647#comment-58869</guid>
		<description>ok! very good!
wonderful!     
thank you! </description>
		<content:encoded><![CDATA[<p>ok! very good!<br />
wonderful!     <br />
thank you!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nike mercurial superfly</title>
		<link>http://www.engineyard.com/blog/2010/mri-memory-allocation-a-primer-for-developers/comment-page-1/#comment-58794</link>
		<dc:creator>nike mercurial superfly</dc:creator>
		<pubDate>Fri, 19 Aug 2011 04:05:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.engineyard.com/blog/?p=3647#comment-58794</guid>
		<description>ok! very good!wonderful!you are right!                  thank you! </description>
		<content:encoded><![CDATA[<p>ok! very good!wonderful!you are right!                  thank you!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tuning the Garbage Collector with Ruby 1.9.2 &#124; Engine Yard Ruby on Rails Blog</title>
		<link>http://www.engineyard.com/blog/2010/mri-memory-allocation-a-primer-for-developers/comment-page-1/#comment-58767</link>
		<dc:creator>Tuning the Garbage Collector with Ruby 1.9.2 &#124; Engine Yard Ruby on Rails Blog</dc:creator>
		<pubDate>Tue, 09 Aug 2011 20:40:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.engineyard.com/blog/?p=3647#comment-58767</guid>
		<description>[...] Haines wrote a very deep technical post about MRI memory allocation in Ruby 1.8 which you can read also. The main concepts are generally applicable in Ruby 1.9 as [...]</description>
		<content:encoded><![CDATA[<p>[...] Haines wrote a very deep technical post about MRI memory allocation in Ruby 1.8 which you can read also. The main concepts are generally applicable in Ruby 1.9 as [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Concurrency, Real and Imagined, in MRI; Threads &#124; Engine Yard Ruby on Rails Blog</title>
		<link>http://www.engineyard.com/blog/2010/mri-memory-allocation-a-primer-for-developers/comment-page-1/#comment-43275</link>
		<dc:creator>Concurrency, Real and Imagined, in MRI; Threads &#124; Engine Yard Ruby on Rails Blog</dc:creator>
		<pubDate>Wed, 11 Aug 2010 01:44:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.engineyard.com/blog/?p=3647#comment-43275</guid>
		<description>[...] unfamiliar with the way memory is managed and garbage is collected in MRI 1.8, you should check out my article on MRI Memory Allocation. One key aspect is that objects carry all of their status bits with them. This means that when the [...]</description>
		<content:encoded><![CDATA[<p>[...] unfamiliar with the way memory is managed and garbage is collected in MRI 1.8, you should check out my article on MRI Memory Allocation. One key aspect is that objects carry all of their status bits with them. This means that when the [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Randy</title>
		<link>http://www.engineyard.com/blog/2010/mri-memory-allocation-a-primer-for-developers/comment-page-1/#comment-42220</link>
		<dc:creator>Randy</dc:creator>
		<pubDate>Tue, 11 May 2010 16:04:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.engineyard.com/blog/?p=3647#comment-42220</guid>
		<description>I was hoping that you could walk down the reference-counting linkage used by the garbage collector to determine when objects can be freed... </description>
		<content:encoded><![CDATA[<p>I was hoping that you could walk down the reference-counting linkage used by the garbage collector to determine when objects can be freed&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kirk Haines</title>
		<link>http://www.engineyard.com/blog/2010/mri-memory-allocation-a-primer-for-developers/comment-page-1/#comment-42219</link>
		<dc:creator>Kirk Haines</dc:creator>
		<pubDate>Tue, 11 May 2010 15:53:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.engineyard.com/blog/?p=3647#comment-42219</guid>
		<description>Randy, there&#039;s no capability like that built into Ruby objects at this time. It would be possible to create that sort of capability, since an object occupies it&#039;s slot in the heap (20 or 40 bytes, depending on architecture, and determinable in code) + its own allocations, which any object could track in an easily reportable way, but it just has not been done. 
 
There are some tricky bits to it, though, that do add a layer of complexity. 
 
Take, for example, this: 
 
irb(main):001:0&gt; a = &quot;abc&quot; 
=&gt; &quot;abc&quot; 
 
So, byte_size on that would be straightforward to calculate, right? 
 
What happens with this, though: 
 
class &lt;&lt; a 
  def scratch 
    @scratch 
  end 
 
  def scratch=(val) 
    @scratch = val 
  end 
end 
 
irb(main):010:0&gt; a.scratch = &quot;def&quot; 
=&gt; &quot;def&quot; 
irb(main):011:0&gt; a 
=&gt; &quot;abc&quot; 
 
Even if String knew how to report on the size of it&#039;s slot + allocations, that wouldn&#039;t be accurate for the String subclass pointed to by &#039;a&#039; in that example, because it stores a second String in an instance variable. 
 
To really be accurate the object implementations would have to keep track of their own allocations, as well as be able to interrogate all of their instance variables for their own size. 
 
And then what happens when you get a cycle? 
 
irb(main):004:0&gt; class UtOh &lt; String 
irb(main):005:1&gt; attr_accessor :trouble 
irb(main):006:1&gt; end 
=&gt; nil 
irb(main):007:0&gt; a = UtOh.new(&#039;abc&#039;) 
=&gt; &quot;abc&quot; 
irb(main):008:0&gt; b = UtOh.new(&#039;xyz&#039;) 
=&gt; &quot;xyz&quot; 
irb(main):009:0&gt; a.trouble = b 
=&gt; &quot;xyz&quot; 
irb(main):010:0&gt; b.trouble = a 
=&gt; &quot;abc&quot; 
irb(main):011:0&gt; a 
=&gt; &quot;abc&quot; 
irb(main):012:0&gt; a.trouble 
=&gt; &quot;xyz&quot; 
irb(main):013:0&gt; a.trouble.trouble 
=&gt; &quot;abc&quot; 
 
So, what&#039;s the size of the UtOh object pointed to by variable &#039;a&#039;? You can figure it out in your head, but for code it becomes interestingly non-trivial. Still doable, but not a project that anyone that I am aware of has undertaken. </description>
		<content:encoded><![CDATA[<p>Randy, there&#039;s no capability like that built into Ruby objects at this time. It would be possible to create that sort of capability, since an object occupies it&#039;s slot in the heap (20 or 40 bytes, depending on architecture, and determinable in code) + its own allocations, which any object could track in an easily reportable way, but it just has not been done. </p>
<p>There are some tricky bits to it, though, that do add a layer of complexity. </p>
<p>Take, for example, this: </p>
<p>irb(main):001:0&gt; a = &quot;abc&quot;<br />
=&gt; &quot;abc&quot; </p>
<p>So, byte_size on that would be straightforward to calculate, right? </p>
<p>What happens with this, though: </p>
<p>class &lt;&lt; a<br />
  def scratch<br />
    @scratch<br />
  end </p>
<p>  def scratch=(val)<br />
    @scratch = val<br />
  end<br />
end </p>
<p>irb(main):010:0&gt; a.scratch = &quot;def&quot;<br />
=&gt; &quot;def&quot;<br />
irb(main):011:0&gt; a<br />
=&gt; &quot;abc&quot; </p>
<p>Even if String knew how to report on the size of it&#039;s slot + allocations, that wouldn&#039;t be accurate for the String subclass pointed to by &#039;a&#039; in that example, because it stores a second String in an instance variable. </p>
<p>To really be accurate the object implementations would have to keep track of their own allocations, as well as be able to interrogate all of their instance variables for their own size. </p>
<p>And then what happens when you get a cycle? </p>
<p>irb(main):004:0&gt; class UtOh &lt; String<br />
irb(main):005:1&gt; attr_accessor :trouble<br />
irb(main):006:1&gt; end<br />
=&gt; nil<br />
irb(main):007:0&gt; a = UtOh.new(&#039;abc&#039;)<br />
=&gt; &quot;abc&quot;<br />
irb(main):008:0&gt; b = UtOh.new(&#039;xyz&#039;)<br />
=&gt; &quot;xyz&quot;<br />
irb(main):009:0&gt; a.trouble = b<br />
=&gt; &quot;xyz&quot;<br />
irb(main):010:0&gt; b.trouble = a<br />
=&gt; &quot;abc&quot;<br />
irb(main):011:0&gt; a<br />
=&gt; &quot;abc&quot;<br />
irb(main):012:0&gt; a.trouble<br />
=&gt; &quot;xyz&quot;<br />
irb(main):013:0&gt; a.trouble.trouble<br />
=&gt; &quot;abc&quot; </p>
<p>So, what&#039;s the size of the UtOh object pointed to by variable &#039;a&#039;? You can figure it out in your head, but for code it becomes interestingly non-trivial. Still doable, but not a project that anyone that I am aware of has undertaken.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Randy</title>
		<link>http://www.engineyard.com/blog/2010/mri-memory-allocation-a-primer-for-developers/comment-page-1/#comment-42217</link>
		<dc:creator>Randy</dc:creator>
		<pubDate>Tue, 11 May 2010 14:15:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.engineyard.com/blog/?p=3647#comment-42217</guid>
		<description>Do you know how to get the actual memory used to store a specific Ruby object?  For example, a single AR model, or a container of 1,000 models, each with a few associated models of one class or another?  Ideally, I&#039;d like a method like:  x.byte_size for any object &#039;x&#039;. </description>
		<content:encoded><![CDATA[<p>Do you know how to get the actual memory used to store a specific Ruby object?  For example, a single AR model, or a container of 1,000 models, each with a few associated models of one class or another?  Ideally, I&#039;d like a method like:  x.byte_size for any object &#039;x&#039;.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

