You can adjust the time when an actor is considered inactive to force frequent garbage collection. Code from the documentation:
ActorRuntime.RegisterActorAsync<MyActor>((context, actorType) => new ActorService(context, actorType, settings: new ActorServiceSettings() { ActorGarbageCollectionSettings = new ActorGarbageCollectionSettings(idleTimeoutInSeconds: 20, scanIntervalInSeconds:20) })) .GetAwaiter() .GetResult();
As you can see, there are two parameters: idleTimeoutInSeconds - after this, an actor who does nothing can be considered for deactivation; scanIntervalInSeconds - time interval during which the service fabric checks actors for their inactivity.
source share