JRuby (please use github issues at http://bugs.jruby.org)
  1. JRuby (please use github issues at http://bugs.jruby.org)
  2. JRUBY-2711

RubyArray keeps references to unreachable RubyObjects after clear, reject!, delete and delete_at

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: JRuby 1.1.2
    • Fix Version/s: JRuby 1.1.3
    • Component/s: Core Classes/Modules
    • Labels:
      None
    • Environment:
      Mac OS X 10.5.3; J2SE 5.0
    • Testcase included:
      yes
    • Patch Submitted:
      Yes
    • Number of attachments :
      1

      Description

      RubyArrays don't explicitly dereference elements that are removed for Array#clear and leave extra references to other elements in the backing values array as the elements are shifted about in the reject!, delete and delete_at implementations. This causes memory leaks in our application as we rely on Array#clear and Array#delete(_at|_if) to remove references to objects so they may be collected.

      Attached is a patch that removes unneeded references to RubyObjects in RubyArray's values array for clear, reject!, delete and delete_at. The patch also includes 4 java unit tests; there is one test for each method which assert invalidated values entries are set to null.

        Activity

        Hide
        Vladimir Sizikov added a comment -

        Indeed! Good find. Will take a look at the patch.

        Show
        Vladimir Sizikov added a comment - Indeed! Good find. Will take a look at the patch.
        Hide
        Vladimir Sizikov added a comment -

        Fixed in rev. r7039 on trunk.

        Patch and tests by Micah Alles. Thanks, much appreciated!

        Show
        Vladimir Sizikov added a comment - Fixed in rev. r7039 on trunk. Patch and tests by Micah Alles. Thanks, much appreciated!

          People

          • Assignee:
            Vladimir Sizikov
            Reporter:
            Micah Alles
          • Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: