Scala Programming Language
  1. Scala Programming Language
  2. SI-3920

Links to exiting actors don't get cleaned up properly

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Misc Library
    • Labels:
      None
    • Environment:

      actors

      Description

      If I link two actors (Parent <-> Child) and Child exits, a reference to it will be kept in Parent#links forever. It can be mitigated somewhat by manually unlinking in Parent when it receives the Exit message, but it is tedious and bug-prone.

      To reproduce this: open a REPL and paste the contents of testcase.scala. Wait until it prints the "child exited" messages and then take a heap dump using any available tool (e.g. jvisualvm). It will show 4 instances of Child as not being available for GC because they're referenced from Parent#links.

      This could probably be fixed easily by changing a line in the exitLinked() method from mylinks.foreach(unlinkFrom()) to mylinks.foreach(.unlinkFrom(this)).

      1. 3920.patch
        0.6 kB
        Jira Admin
      2. testcase.scala
        0.6 kB
        Jira Admin

        Activity

        Hide
        Alexey Ermakov added a comment -

        Test case

        Show
        Alexey Ermakov added a comment - Test case
        Hide
        Alexey Ermakov added a comment -

        Changing the unlinkFrom invocation as described leads to deadlock.

        I've attached the patch that fixes the issue by removing the links a bit later. I've tested the fix on our system and it seems to work correctly.

        Show
        Alexey Ermakov added a comment - Changing the unlinkFrom invocation as described leads to deadlock. I've attached the patch that fixes the issue by removing the links a bit later. I've tested the fix on our system and it seems to work correctly.
        Hide
        Philipp Haller added a comment -

        (In r23370) Closes SI-3920. Review by prokopec.

        Show
        Philipp Haller added a comment - (In r23370) Closes SI-3920 . Review by prokopec.

          People

          • Assignee:
            Philipp Haller
            Reporter:
            Alexey Ermakov
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development