More Scala Actor Gc

if I want to implement am http server.

I create a new member upon request. This way it can scale as my processor updates.

but will this cause a memory issue? They say that the actor has strange behavior, and gc. the code will be anyway:

class Worker extends Actor { def act = react { case req : Request => perform(req);exit() } } class HttpEventHandler{ def onConnect(conn) = { new Worker ! createRequest(conn) } } 

Edit: I did a test about this, checked my test in detail http://jilen.iteye.com/blog/1231178

+6
source share
1 answer

The climb had some problems with the Scala built-in actor library a couple of years ago, which prompted them to write their own acting library. I have no idea if Scala had built-in members all of the same problems that the Lift community was facing then. You will need to do your own testing to find out. (Or maybe someone with recent experience can call back).

I recommend checking out the Akka Actors library. All in all, I think this is an improvement on Scala's built-in implementation. It even has a spawn function that does exactly what you are doing here (creating an actor to process a single message and skill).

Edit:

The code you entered, in particular, is likely to be an actor leak, since you obviously do not exit() your actors when you are done with them.

Edit 2:

It turns out that Scala has a spawn function (thanks Stefan). I don't know if it works better than Scala.

+3
source

Source: https://habr.com/ru/post/900484/


All Articles