Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Another actors memory leak? #1948

Closed
scabug opened this issue May 3, 2009 · 6 comments
Closed

Another actors memory leak? #1948

scabug opened this issue May 3, 2009 · 6 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented May 3, 2009

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

  1. 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))
@scabug
Copy link
Author

scabug commented May 3, 2009

Imported From: https://issues.scala-lang.org/browse/SI-1948?orig=1
Reporter: Alex Yakovlev (alex14n)

@scabug
Copy link
Author

scabug commented May 4, 2009

@phaller said:
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.

@scabug
Copy link
Author

scabug commented May 4, 2009

Alex Yakovlev (alex14n) said:
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) }
}
}

@scabug
Copy link
Author

scabug commented May 4, 2009

Alex Yakovlev (alex14n) said:
Sry, I meant "much" and "new Array[Int] (1000000)"

@scabug
Copy link
Author

scabug commented Jun 3, 2009

Alex Yakovlev (alex14n) said:
it was not fixed in 2.7.5 :(

@scabug
Copy link
Author

scabug commented Jul 2, 2009

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

@scabug scabug closed this as completed May 18, 2011
@scabug scabug added this to the 2.8.0 milestone Apr 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants