초기 컨텍스트로드 중 콩을 인스턴스화 할 때 이상한 스프링 동작을 발견했습니다. 큰 ML 모델을로드하는 bean이 있습니다. 메모리 부족으로 인해 Bean을 인스턴스화하지 못했습니다. Java OutOfMemoryError
Java 힙 공간 예외. 하지만 응용 프로그램이 인스턴스화되는 것을 멈추지 않고 응용 프로그램을 계속로드합니다.Bean이 인스턴스 생성에 실패하더라도 Spring이 컨텍스트를 초기화하는 이유는 무엇입니까?
왜 이런 일이 발생합니까? 예상 되나요?
봄AbstractAutowireCapableBeanFactory
, 그것은
// Finished partial creation of this bean.
이 응용 프로그램의 안정성에 영향을 미치지 않습니다 자동으로 코멘트와 함께 예외를 소화
try {
// Mark this bean as currently in creation, even if just partially.
beforeSingletonCreation(beanName);
// Give BeanPostProcessors a chance to return a proxy instead of the target bean instance.
instance = resolveBeforeInstantiation(beanName, mbd);
if (instance == null) {
bw = createBeanInstance(beanName, mbd, null);
instance = bw.getWrappedInstance();
}
}
finally {
// Finished partial creation of this bean.
afterSingletonCreation(beanName);
}
을 확인? 왜 그렇게 설계 되었습니까?
아니면 뭔가 빠졌습니까?