Details

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

      actors, leak

      Description

      There seems to be another leak in actors. We use actors to pass large object, so any left references to messages takes tens megabytes of memory.

      In Memory Analyzer report I see `scala.actors.Actor.received` as possible suspect. Not 100% sure yet, and still have no code to reproduce this bug, but looking at code:

      1) Both at the end of receive and receiveWithin there is:

      val result = f(received.get)
      sessions = sessions.tail
      result

      `received` here is processed but not cleares, so I suggest adding:

      received = None

      2) `received` is processed only in `receive` method. But `send` methods sets it in any case:

      received = Some(msg)
      ...
      if (isSuspended)
      resumeActor()
      else // assert continuation != null
      scheduler.execute(new Reaction(this, continuation, msg))

      As far as I can understand, `received` should be set only if `isSuspended` (for `receive`). `react` processes it as `new Reaction` argument. So I suggest delete this line at the beginning of `send` method:

      received = Some(msg)

      and modify:

      if (isSuspended)

      { received = Some(msg) resumeActor() }

      else // assert continuation != null
      scheduler.execute(new Reaction(this, continuation, msg))

        Activity

        Hide
        Philipp Haller added a comment -

        Hi Alex, that's a great suggestion, thanks! Even if we don't know whether it resolves the original problem it's a good idea to do that. I just implemented this in trunk (r17631). Please open a new ticket if the problem persists.

        Show
        Philipp Haller added a comment - Hi Alex, that's a great suggestion, thanks! Even if we don't know whether it resolves the original problem it's a good idea to do that. I just implemented this in trunk (r17631). Please open a new ticket if the problem persists.
        Hide
        Alex Yakovlev added a comment -

        Great! Thank you very muck for such a quick responce!
        Just in case, code to reproduce this bug. Now it is fixed, I confirm it.

        import scala.actors._
        import scala.actors.Actor._

        object Ticket1948 {
        def main (args: Array[String]) {
        val actors = (1 to 1000).toList map { x => actor { loop { react

        { case x: Array[Int] => reply ("OK"); exit }

        }}
        actors foreach

        { x => x !? new Array[Int] (1000) }

        }
        }

        Show
        Alex Yakovlev added a comment - Great! Thank you very muck for such a quick responce! Just in case, code to reproduce this bug. Now it is fixed, I confirm it. import scala.actors._ import scala.actors.Actor._ object Ticket1948 { def main (args: Array [String] ) { val actors = (1 to 1000).toList map { x => actor { loop { react { case x: Array[Int] => reply ("OK"); exit } }} actors foreach { x => x !? new Array[Int] (1000) } } }
        Hide
        Alex Yakovlev added a comment -

        Sry, I meant "much" and "new Array[Int] (1000000)"

        Show
        Alex Yakovlev added a comment - Sry, I meant "much" and "new Array [Int] (1000000)"
        Hide
        Alex Yakovlev added a comment -

        it was not fixed in 2.7.5

        Show
        Alex Yakovlev added a comment - it was not fixed in 2.7.5
        Hide
        Philipp Haller added a comment -

        I added the test in r18199 (trunk). Trunk (2.8.x) no longer has this problem. Therefore, I am closing the ticket.

        Show
        Philipp Haller added a comment - I added the test in r18199 (trunk). Trunk (2.8.x) no longer has this problem. Therefore, I am closing the ticket.

          People

          • Assignee:
            Philipp Haller
            Reporter:
            Alex Yakovlev
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development