संपादित करें

Share via

Delete Reliable Actors and their state

Garbage collection of deactivated actors only cleans up the actor object, but it does not remove data that is stored in an actor's State Manager. When an actor is reactivated, its data is again made available to it through the State Manager. In cases where actors store data in State Manager and are deactivated but never reactivated, it may be necessary to clean up their data.

The Actor Service provides a function for deleting actors from a remote caller:

ActorId actorToDelete = new ActorId(id);

IActorService myActorServiceProxy = ActorServiceProxy.Create(
    new Uri("fabric:/MyApp/MyService"), actorToDelete);

await myActorServiceProxy.DeleteActorAsync(actorToDelete, cancellationToken)
ActorId actorToDelete = new ActorId(id);

ActorService myActorServiceProxy = ActorServiceProxy.create(
    new Uri("fabric:/MyApp/MyService"), actorToDelete);


Deleting an actor has the following effects depending on whether or not the actor is currently active:

  • Active Actor
    • Actor is removed from active actors list and is deactivated.
    • Its state is deleted permanently.
  • Inactive Actor
    • Its state is deleted permanently.

An actor cannot call delete on itself from one of its actor methods because the actor cannot be deleted while executing within an actor call context, in which the runtime has obtained a lock around the actor call to enforce single-threaded access.

For more information on Reliable Actors, read the following: