# Ruby 1.9 bug, no copy-on-write for MatchData#post\_match

**URL:** <https://www.ruby-forum.com/t/ruby-1-9-bug-no-copy-on-write-for-matchdata-post-match/128296>\
**Category:** Ruby\
**Created:** [February 6, 2008, 3:36pm UTC](https://www.ruby-forum.com/t/ruby-1-9-bug-no-copy-on-write-for-matchdata-post-match/128296 "2008-02-06T15:36:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![faina](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/a3d4f5/32.png) [@faina](https://www.ruby-forum.com/u/faina)\
**Post date:** [February 6, 2008, 3:36pm UTC](https://www.ruby-forum.com/t/ruby-1-9-bug-no-copy-on-write-for-matchdata-post-match/128296/1 "2008-02-06T15:36:02Z")

</div>

As we found during ruby quiz 155, there is a bug in copy-on-write for  
Ruby 1.9.

The following code

size = 100000 \* 100  
s = “x” \* size  
a = []  
while (m = s.match(/^./))  
s = m.post\_match  
a \<\< s  
end

takes 700 megabytes of memory under Ruby 1.8.6; under 1.9.0 instead I  
had to remove the “\* 100” factor, and even like that it took more than  
2 gigabytes.

I guess that an isolated post will be more easily spotted by  
interested people than something hidden under ruby quiz. 🙂

Paolo
