Ruby 1.9 bug, no copy-on-write for MatchData#post_match

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. :slight_smile:

Paolo

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs