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

Memory leak during actor creation. #439

Open
devas123 opened this issue Jun 10, 2022 · 1 comment
Open

Memory leak during actor creation. #439

devas123 opened this issue Jun 10, 2022 · 1 comment

Comments

@devas123
Copy link

devas123 commented Jun 10, 2022

When creating a new actor in the following code:

map <- refActorMap.get
finalName <- buildFinalName(parentActor.getOrElse(""), actorName)
_ <- if (map.contains(finalName)) IO.fail(new Exception(s"Actor $finalName already exists")) else IO.unit
path = buildPath(actorSystemName, finalName, remoteConfig)
derivedSystem = new ActorSystem(actorSystemName, config, remoteConfig, refActorMap, Some(finalName))
childrenSet <- Ref.make(Set.empty[ActorRef[Any]])
actor <- stateful.makeActor(
sup,
new Context(path, derivedSystem, childrenSet),
() => dropFromActorMap(path, childrenSet)
)(init)
_ <- refActorMap.set(map + (finalName -> actor))

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
Copy link
Author

devas123 commented Jun 10, 2022

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

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

1 participant