mike
mike

Reputation: 133

SelectChildName messages from RemoteDeadLetterActorRef

I have two actor systems that communicate via akka remoting.

When I take a look into the JVM heap I am seeing (too) many instances of akka.dispatch.Envelope containing SelectChildName messages from akka.remote.RemoteActorRefProvider$RemoteDeadLetterActorRef.

The retained heap of these messages is pretty large and causes memory problems.

What is the purpose of these SelectChildName messages? Is there a way to avoid them?

FYI This seems to relate with Disassociation errors that occur between the two actor systems.

Thanks, Michail

Upvotes: 0

Views: 127

Answers (1)

Stefano Bonetti
Stefano Bonetti

Reputation: 9023

SelectChildName messages are used by Akka Remoting to resolve a remote actor. If you see a lot of them, there is a chance you are interacting directly with an ActorSelection, instead of an ActorRef.

Every time you send a message to an ActorSelection, for example (these are taken from the docs)

val selection = context.actorSelection("akka.tcp://[email protected]:2552/user/actorName")
selection ! "Pretty awesome feature"

the - possibly remote - actor is resolved, and that involves exchanging of SelectChildName messages by the underlying Akka infrastructure.

If that's the case, try and use directly ActorRefs. You can obtain one from an ActorSelection by using the resolveOne method.

Citing the docs again:

It is always preferable to communicate with other Actors using their ActorRef instead of relying upon ActorSelection. Exceptions are

  • sending messages using the At-Least-Once Delivery facility
  • initiating first contact with a remote system

Upvotes: 1

Related Questions