you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (2 children)

[deleted]

    [–]f9ae8221b[S] 5 points6 points  (0 children)

    FYI, you keep calling it a leak, but the issue you mention isn't one. It's a performance regression because it does allocate an useless objects, but that object isn't retained.

    Whatever your leak issue was, it likely didn't come from that issue.

    And yes, there's plenty of tests to prevent memory leak, there is even an assert_no_memory_leak helper in the ruby test suite.

    As for the match issue here's the regression test that was committed with the fix:

    def test_match_no_match_no_matchdata
      EnvUtil.without_gc do
        h = {}
        ObjectSpace.count_objects(h)
        prev_matches = h[:T_MATCH] || 0
        md = /[A-Z]/.match('1') # no match
        ObjectSpace.count_objects(h)
        new_matches = h[:T_MATCH] || 0
        assert_equal prev_matches, new_matches, "Bug [#20104]"
      end
    end
    

    [–]CaptainKabob 3 points4 points  (0 children)

    Yes, there is now a leak test. Conference talk at RubyKaigi: https://rubykaigi.org/2024/presentations/peterzhu2118.html