저는 AKKA 문서의 샘플 클러스터 응용 프로그램 중 하나를 프로파일 링 (visualvm)하고 모든 GC 동안 요청 별 액터를 정리하는 가비지 콜렉션을 봅니다. 사용 후 명시 적으로 배우를 죽이는 권장 사항을 완전히 이해할 수 없습니다. 내 액터 시스템과 액터는 SPRING IOC 컨테이너에 의해 관리되며 저는 스프링 확장 직접 직접 액터 프로듀서를 사용하여 액터를 만듭니다. "어 그리 게이터"액터가 모든 GC에서 가비지 수집 중입니다. 시각적 VM의 인스턴스 수를 모니터했습니다.
@Component
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class StatsService extends AbstractActor {
private final LoggingAdapter log = Logging.getLogger(getContext().getSystem(), this);
@Autowired
private ActorSystem actorSystem;
private ActorRef workerRouter;
@Override
public void preStart() throws Exception {
System.out.println("Creating Router" + this.getClass().getCanonicalName());
workerRouter = getContext().actorOf(SPRING_PRO.get(actorSystem)
.props("statsWorker").withRouter(new FromConfig()), "workerRouter");
super.preStart();
}
@Override
public Receive createReceive() {
return receiveBuilder()
.match(StatsJob.class, job -> !job.getText().isEmpty(), job -> {
final String[] words = job.getText().split(" ");
final ActorRef replyTo = sender();
final ActorRef aggregator = getContext().actorOf(SPRING_PRO.get(actorSystem)
.props("statsAggregator", words.length, replyTo));
for (final String word : words) {
workerRouter.tell(new ConsistentHashableEnvelope(word, word),
aggregator);
}
})
.build();
}
}
http : // stackoverflow.com/questions/23066264/can-wrapping-akka-actors-in-class-actors에 의한 메모리 누수 <- 관련 질문 –