zio / zio-actors

A high-performance, purely-functional library for building, composing, and supervising typed actors based on ZIO
https://zio.dev/zio-actors
Apache License 2.0
268 stars 56 forks source link

Memory leak during actor creation. #439

Open devas123 opened 2 years ago

devas123 commented 2 years ago

When creating a new actor in the following code:

https://github.com/zio/zio-actors/blob/1560ff2d2cc000cf36313b5ebf659467f5a5a191/actors/src/main/scala/zio/actors/ActorSystem.scala#L132-L143

If the actor stops and calls dropFromActorMap before it gets added to the actor map at line 143, the map will be updated with a reference to a dead actor, which creates a memory leak.

devas123 commented 2 years ago

A quick solution could be to pass a Promise to the dropFromActorMap, which will be resolved after the map has been updated.