# Trouble squashing Ruby bug

**URL:** <https://www.ruby-forum.com/t/trouble-squashing-ruby-bug/102437>\
**Category:** Ruby\
**Created:** [August 15, 2006, 2:17pm UTC](https://www.ruby-forum.com/t/trouble-squashing-ruby-bug/102437 "2006-08-15T14:17:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![joe-black](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/87869e/32.png) [@joe-black](https://www.ruby-forum.com/u/joe-black)\
**Post date:** [August 15, 2006, 2:17pm UTC](https://www.ruby-forum.com/t/trouble-squashing-ruby-bug/102437/1 "2006-08-15T14:17:23Z")

</div>

I’m writing a c++ Ruby extension that seems to be running into some  
kind of a memory issue. I’m getting “HEAP: free heap block modified  
after it was freed” when I attempt to either allocate a new  
array(rb\_ary\_new) or push onto a ruby array(rb\_ary\_push) at a certain  
point in my program. I can’t seem to find any buffer overflows - which  
I believe is one cause for such an error. So it leads me to believe  
that maybe my “marking” functionality may be flawed. But as far as I  
can see I’m handling the marking properly - I mark anything that is not  
a fixnum( arrays, other classes, etc). Are there any newbie marking  
mistakes anyone knows of that could cause an issue like this?

This problem only happens when my extension uses a decent amount of  
memory - so I’m not sure if there is some kind of a Ruby heap limit  
that I’m going over.

I’m just curious if anyone has encountered a problem similar to this  
that they have overcome? Its been almost a week where I have  
essentially been at a standstill with development. I’ve even got an  
evaluation of Insure++ to help me look for memory issues - all to no  
avail.

Thanks, Let me know if there is any additional information I can  
provide to clarify any details.

Joe

---

<div class="post-metadata">

**Author:** ![joe-black](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/87869e/32.png) [@joe-black](https://www.ruby-forum.com/u/joe-black)\
**Post date:** [August 15, 2006, 2:18pm UTC](https://www.ruby-forum.com/t/trouble-squashing-ruby-bug/102437/2 "2006-08-15T14:18:06Z")

</div>

> I’m writing a c++ Ruby extension that seems to be running into some  
> kind of a memory issue.

Whether you are using SWIG or not, their Ruby memory management  
documentation may be helpful. It was for me.

[http://www.swig.org/Doc1.3/Ruby.html#Ruby\_nn57](http://www.swig.org/Doc1.3/Ruby.html#Ruby_nn57)

Good luck!

---

<div class="post-metadata">

**Author:** ![joe-black](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/87869e/32.png) [@joe-black](https://www.ruby-forum.com/u/joe-black)\
**Post date:** [August 15, 2006, 2:18pm UTC](https://www.ruby-forum.com/t/trouble-squashing-ruby-bug/102437/3 "2006-08-15T14:18:25Z")

</div>

rickhg12hs wrote:

> > I’m writing a c++ Ruby extension that seems to be running into some  
> > kind of a memory issue.
> 
> Whether you are using SWIG or not, their Ruby memory management  
> documentation may be helpful. It was for me.
> 
> [SWIG and Ruby](http://www.swig.org/Doc1.3/Ruby.html#Ruby_nn57)
> 
> Good luck!

Thanks - I’ll check that out
