<?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"
	>
<channel>
	<title>Comments on: Ruby to C, a couple snippets</title>
	<atom:link href="http://macournoyer.wordpress.com/2008/04/16/ruby-to-c-a-couple-snippets/feed/" rel="self" type="application/rss+xml" />
	<link>http://macournoyer.wordpress.com/2008/04/16/ruby-to-c-a-couple-snippets/</link>
	<description>My software passion spreading place</description>
	<pubDate>Thu, 22 May 2008 20:28:12 +0000</pubDate>
	<generator>http://wordpress.org/?v=MU</generator>
		<item>
		<title>By: Andre</title>
		<link>http://macournoyer.wordpress.com/2008/04/16/ruby-to-c-a-couple-snippets/#comment-10175</link>
		<dc:creator>Andre</dc:creator>
		<pubDate>Tue, 06 May 2008 18:36:41 +0000</pubDate>
		<guid isPermaLink="false">http://macournoyer.wordpress.com/2008/04/16/ruby-to-c-a-couple-snippets/#comment-10175</guid>
		<description>==19019== LEAK SUMMARY:
==19019==    definitely lost: 0 bytes in 0 blocks.
==19019==      possibly lost: 16 bytes in 1 blocks.
==19019==    still reachable: 17,390,960 bytes in 377,007 blocks.

That was for a single run... for two runs, "still reachable" grows:

==19126== LEAK SUMMARY:
==19126==    definitely lost: 0 bytes in 0 blocks.
==19126==      possibly lost: 16 bytes in 1 blocks.
==19126==    still reachable: 19,404,620 bytes in 356,601 blocks.
==19126==         suppressed: 0 bytes in 0 blocks.

I guess this means there's stuff being kept around that's not being dereferenced, and the GC can't do anything about it :(</description>
		<content:encoded><![CDATA[<p>==19019== LEAK SUMMARY:<br />
==19019==    definitely lost: 0 bytes in 0 blocks.<br />
==19019==      possibly lost: 16 bytes in 1 blocks.<br />
==19019==    still reachable: 17,390,960 bytes in 377,007 blocks.</p>
<p>That was for a single run&#8230; for two runs, &#8220;still reachable&#8221; grows:</p>
<p>==19126== LEAK SUMMARY:<br />
==19126==    definitely lost: 0 bytes in 0 blocks.<br />
==19126==      possibly lost: 16 bytes in 1 blocks.<br />
==19126==    still reachable: 19,404,620 bytes in 356,601 blocks.<br />
==19126==         suppressed: 0 bytes in 0 blocks.</p>
<p>I guess this means there&#8217;s stuff being kept around that&#8217;s not being dereferenced, and the GC can&#8217;t do anything about it <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: macournoyer</title>
		<link>http://macournoyer.wordpress.com/2008/04/16/ruby-to-c-a-couple-snippets/#comment-10150</link>
		<dc:creator>macournoyer</dc:creator>
		<pubDate>Tue, 06 May 2008 14:13:25 +0000</pubDate>
		<guid isPermaLink="false">http://macournoyer.wordpress.com/2008/04/16/ruby-to-c-a-couple-snippets/#comment-10150</guid>
		<description>If you needed to play w/ rb_register_address you'd have segfaults while accessing memory that has been freed by the GC.

You might have a memory leak in your C code if it's increasing rapidly. I use Valgrind to hunt mem leaks: http://blog.evanweaver.com/articles/2008/02/05/valgrind-and-ruby/</description>
		<content:encoded><![CDATA[<p>If you needed to play w/ rb_register_address you&#8217;d have segfaults while accessing memory that has been freed by the GC.</p>
<p>You might have a memory leak in your C code if it&#8217;s increasing rapidly. I use Valgrind to hunt mem leaks: <a href="http://blog.evanweaver.com/articles/2008/02/05/valgrind-and-ruby/" rel="nofollow">http://blog.evanweaver.com/articles/2008/02/05/valgrind-and-ruby/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andre</title>
		<link>http://macournoyer.wordpress.com/2008/04/16/ruby-to-c-a-couple-snippets/#comment-10137</link>
		<dc:creator>Andre</dc:creator>
		<pubDate>Tue, 06 May 2008 12:14:16 +0000</pubDate>
		<guid isPermaLink="false">http://macournoyer.wordpress.com/2008/04/16/ruby-to-c-a-couple-snippets/#comment-10137</guid>
		<description>Well, I actually am writing a large part of the application in C with the ruby API, because performance is really important. It's an application that simulates message passing in a graph with thousands of nodes, and each message is a ruby array.

I'm not doing anything explicit to work with the garbage collector, because I thought that it was only needed for global objects and C struct fields that are VALUEs. However, memory usage is increasing a lot when the program runs for a long time (it runs for a few days).

I'm not sure if this is just ruby's conservative GC that isn't freeing my objects, or if there's something I should be doing to let it do its job...</description>
		<content:encoded><![CDATA[<p>Well, I actually am writing a large part of the application in C with the ruby API, because performance is really important. It&#8217;s an application that simulates message passing in a graph with thousands of nodes, and each message is a ruby array.</p>
<p>I&#8217;m not doing anything explicit to work with the garbage collector, because I thought that it was only needed for global objects and C struct fields that are VALUEs. However, memory usage is increasing a lot when the program runs for a long time (it runs for a few days).</p>
<p>I&#8217;m not sure if this is just ruby&#8217;s conservative GC that isn&#8217;t freeing my objects, or if there&#8217;s something I should be doing to let it do its job&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: macournoyer</title>
		<link>http://macournoyer.wordpress.com/2008/04/16/ruby-to-c-a-couple-snippets/#comment-10101</link>
		<dc:creator>macournoyer</dc:creator>
		<pubDate>Tue, 06 May 2008 00:44:04 +0000</pubDate>
		<guid isPermaLink="false">http://macournoyer.wordpress.com/2008/04/16/ruby-to-c-a-couple-snippets/#comment-10101</guid>
		<description>@Andre: If the object is passed back to Ruby you don't need to do anything. Like in your example, you don't need to register the address, since you return blah to Ruby.
Unless you write large part of your application in C you won't need to bother w/ this.</description>
		<content:encoded><![CDATA[<p>@Andre: If the object is passed back to Ruby you don&#8217;t need to do anything. Like in your example, you don&#8217;t need to register the address, since you return blah to Ruby.<br />
Unless you write large part of your application in C you won&#8217;t need to bother w/ this.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andre</title>
		<link>http://macournoyer.wordpress.com/2008/04/16/ruby-to-c-a-couple-snippets/#comment-10076</link>
		<dc:creator>Andre</dc:creator>
		<pubDate>Mon, 05 May 2008 19:08:01 +0000</pubDate>
		<guid isPermaLink="false">http://macournoyer.wordpress.com/2008/04/16/ruby-to-c-a-couple-snippets/#comment-10076</guid>
		<description>Could you clarify a bit on the GC? What do you mean with "long lived objects"? Do I need to do something explicitely in code like

VALUE
foo(void)
{
  VALUE blah = rb_ary_new();
  append_stuff_to(blah);
  return blah;
}

?

Thanks!</description>
		<content:encoded><![CDATA[<p>Could you clarify a bit on the GC? What do you mean with &#8220;long lived objects&#8221;? Do I need to do something explicitely in code like</p>
<p>VALUE<br />
foo(void)<br />
{<br />
  VALUE blah = rb_ary_new();<br />
  append_stuff_to(blah);<br />
  return blah;<br />
}</p>
<p>?</p>
<p>Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: roger pack</title>
		<link>http://macournoyer.wordpress.com/2008/04/16/ruby-to-c-a-couple-snippets/#comment-9575</link>
		<dc:creator>roger pack</dc:creator>
		<pubDate>Mon, 28 Apr 2008 16:46:54 +0000</pubDate>
		<guid isPermaLink="false">http://macournoyer.wordpress.com/2008/04/16/ruby-to-c-a-couple-snippets/#comment-9575</guid>
		<description>Also I think you don't need to worry about explicit garbage marking if your object is passed back to some ruby object, or contained within another object that is referenced, where the 'larger, containing object' has the gc_something[?] function which tells the GC 'these are my children, don't collect them!' during a sweep. Something like that :)</description>
		<content:encoded><![CDATA[<p>Also I think you don&#8217;t need to worry about explicit garbage marking if your object is passed back to some ruby object, or contained within another object that is referenced, where the &#8216;larger, containing object&#8217; has the gc_something[?] function which tells the GC &#8216;these are my children, don&#8217;t collect them!&#8217; during a sweep. Something like that <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stephane Wirtel</title>
		<link>http://macournoyer.wordpress.com/2008/04/16/ruby-to-c-a-couple-snippets/#comment-9570</link>
		<dc:creator>Stephane Wirtel</dc:creator>
		<pubDate>Mon, 21 Apr 2008 14:20:19 +0000</pubDate>
		<guid isPermaLink="false">http://macournoyer.wordpress.com/2008/04/16/ruby-to-c-a-couple-snippets/#comment-9570</guid>
		<description>Hi Marc, 

I think you can add the following link: http://whytheluckystiff.net/ruby/pickaxe/html/ext_ruby.html, This is the chapter 'Extending Ruby' from PickAxe.</description>
		<content:encoded><![CDATA[<p>Hi Marc, </p>
<p>I think you can add the following link: <a href="http://whytheluckystiff.net/ruby/pickaxe/html/ext_ruby.html" rel="nofollow">http://whytheluckystiff.net/ruby/pickaxe/html/ext_ruby.html</a>, This is the chapter &#8216;Extending Ruby&#8217; from PickAxe.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: macournoyer</title>
		<link>http://macournoyer.wordpress.com/2008/04/16/ruby-to-c-a-couple-snippets/#comment-9563</link>
		<dc:creator>macournoyer</dc:creator>
		<pubDate>Thu, 17 Apr 2008 02:05:41 +0000</pubDate>
		<guid isPermaLink="false">http://macournoyer.wordpress.com/2008/04/16/ruby-to-c-a-couple-snippets/#comment-9563</guid>
		<description>@Nate yeah I saw rocaml, sadly I don’t know OCaml yet, but the exceptions interception and type conversion does look very nice.

@drnic very cool! I guess we really are ready to Rails to C then :/</description>
		<content:encoded><![CDATA[<p>@Nate yeah I saw rocaml, sadly I don’t know OCaml yet, but the exceptions interception and type conversion does look very nice.</p>
<p>@drnic very cool! I guess we really are ready to Rails to C then :/</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dr Nic</title>
		<link>http://macournoyer.wordpress.com/2008/04/16/ruby-to-c-a-couple-snippets/#comment-9561</link>
		<dc:creator>Dr Nic</dc:creator>
		<pubDate>Wed, 16 Apr 2008 22:33:09 +0000</pubDate>
		<guid isPermaLink="false">http://macournoyer.wordpress.com/2008/04/16/ruby-to-c-a-couple-snippets/#comment-9561</guid>
		<description>If you want to bundle all this in a gem, the newgem generator includes an ext_conf generator (script/generate ext_conf libname) to create an ext/libname/... + test/test_libname_extn.rb file so you can TDD your C.</description>
		<content:encoded><![CDATA[<p>If you want to bundle all this in a gem, the newgem generator includes an ext_conf generator (script/generate ext_conf libname) to create an ext/libname/&#8230; + test/test_libname_extn.rb file so you can TDD your C.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nate</title>
		<link>http://macournoyer.wordpress.com/2008/04/16/ruby-to-c-a-couple-snippets/#comment-9560</link>
		<dc:creator>Nate</dc:creator>
		<pubDate>Wed, 16 Apr 2008 21:08:43 +0000</pubDate>
		<guid isPermaLink="false">http://macournoyer.wordpress.com/2008/04/16/ruby-to-c-a-couple-snippets/#comment-9560</guid>
		<description>Also check out rocml!

http://eigenclass.org/hiki/rocaml

It's fun!</description>
		<content:encoded><![CDATA[<p>Also check out rocml!</p>
<p><a href="http://eigenclass.org/hiki/rocaml" rel="nofollow">http://eigenclass.org/hiki/rocaml</a></p>
<p>It&#8217;s fun!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
