2014-09-09 2 views
3

우리의 웹 플로우 (2.3.1) 애플리케이션은 브라우저를 통해 열리는 각각의 새로운 플로우에 대해 많은 메모리를 요구하고 있습니다.많은 메모리를 사용하는 스프링 웹 플로우

아래 스크린 샷은 애플리케이션의 메모리 사용을 보여줍니다. 응용 프로그램이 시작될 때 초기 400MB가 필요합니다.

<?xml version="1.0" encoding="UTF-8"?> 
<flow xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xmlns="http://www.springframework.org/schema/webflow" 
     xsi:schemaLocation="http://www.springframework.org/schema/webflow 
            http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd" start-state="start"> 
    <view-state id="start" view="test/test1"> 
    </view-state> 
    <end-state id="end"/> 
    <bean-import resource="../flow-beans.xml"/> 
</flow> 
: 그 후 우리는 각 테스트 페이지가 자신의 간단한 흐름 정의에서 시작

enter image description here

4 개인, 각각의 추가 메모리 90MB에 대해 주장하는 브라우저에서 동일한 Webflow 테스트 페이지를 ... 열

JSP 테스트 페이지도 매우 간단하며 텍스트 한 줄만 있으면됩니다.

현재 JVM 메모리를 1.5Gb로 설정하면 약 15 개의 다른 플로우를 연 후 OutOfMemoryExceptions가있는 서버에서 응용 프로그램이 충돌합니다. 화면의 복잡도가 낮아서 1.5Gb가 다소 복잡해 보입니다.

메모리 흐름이 이러한 간단한 흐름/페이지에 대한 클레임이 예상되는지, 따라서 더 많은 메모리를 할당해야하는지 궁금합니다. 서버 JVM 그렇지 않은 경우이 메모리 사용을 어떻게 줄일 수 있는지 알고 싶습니다.

다음은 Google의 전체 웹 구성입니다.

우리는 flow-execution-repository 태그를 추가하고 max-executions-snapshots 및 max-execution 값으로 놀았지만, 가장 보수적 인 설정조차도 우리가 보는 메모리 사용을 변경하지 않습니다.

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:webflow="http://www.springframework.org/schema/webflow-config" 
    xmlns:tx="http://www.springframework.org/schema/tx" 
    xsi:schemaLocation=" 
     http://www.springframework.org/schema/beans 
     http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
     http://www.springframework.org/schema/webflow-config 
     http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.3.xsd 
     http://www.springframework.org/schema/tx 
     http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"> 

    <!-- Launches new flow executions and resumes existing executions. --> 

    <webflow:flow-executor id="flowExecutor" flow-registry="flowRegistry"> 
    </webflow:flow-executor> 

    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> 
     <property name="location" value="classpath:our.properties" /> 
     <property name="placeholderPrefix" value="$xxxx"></property> 
    </bean> 

    <tx:annotation-driven transaction-manager="$xxxx{txManager}" /> 

    <!-- Creates the registry of flow definitions for this application --> 
    <webflow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices"> 
     <webflow:flow-location-pattern value="classpath:flows/**/*-flow.xml" /> 
    </webflow:flow-registry> 

    <bean id="viewFactoryCreator" class="org.springframework.webflow.mvc.builder.MvcViewFactoryCreator"> 
     <property name="viewResolvers" ref="viewResolver" /> 
    </bean> 

    <bean id="expressionParser" class="org.springframework.expression.spel.standard.SpelExpressionParser"> 
     <constructor-arg name="configuration"> 
      <bean class="org.springframework.expression.spel.SpelParserConfiguration"> 
      <constructor-arg name="autoGrowCollections" value="true" /> 
      <constructor-arg name="autoGrowNullReferences" value="false" /> 
      </bean> 
     </constructor-arg> 
    </bean> 

    <bean id="webflowExpressionParser" class="org.springframework.webflow.expression.spel.WebFlowSpringELExpressionParser"> 
     <constructor-arg name="expressionParser" ref="expressionParser" /> 
    </bean> 

    <webflow:flow-builder-services id="flowBuilderServices" view-factory-creator="viewFactoryCreator" validator="validator" expression-parser="webflowExpressionParser"/> 

    <bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean" /> 


    <bean id="projectVersion" class="our.company.versions.ProjectVersionUtil"> 
     <property name="xxxxVersion" value="$xxxx{xxxx.version}" /> 
     <property name="systemConfigurationDao">  
      <ref bean="SystemConfigurationDao"/> 
     </property> 
    </bean> 

</beans> 
+2

나는 필요할 때마다 싱글 톤을 기본적으로 다시로드하고 있다고 생각합니다. 나는 당신의'flow-beans.xml'이 어플리케이션 싱글 톤이어야하지만 각 플로우 인스턴스에 대해 재로드되는 빈을 포함하고 있다고 생각합니다. –

+0

바인더의 생성자 중 하나에 중단 점을 넣었고 액세스 할 때마다 새로운 흐름에 도달하기 때문에 올바른 것으로 보입니다. 나는 이것을 더 깊이 조사 할 것이고, 나중에 더 많이 돌아올 것이다. 정말 고마워. – Julius

+0

또한 web.xml 및 * -flow xmls가 구성된 방법을 보여줍니다. – Prasad

답변

2

봄 웹 흐름은 기본적으로 XML 파일을로드하고 추가 XML 파일을 가져 오는 새로운 BeanFactory을 구성하는 새로운 흐름을 시작합니다. 새로 생성 된 BeanFactory의 컨텍스트는 DispatcherServlet입니다.

이제는 빈 팩토리가 가져온 XML 파일에 정의 된 bean조차도 모든 빈의 인스턴스를 구성한다는 점에서 문제가 있습니다.

<bean-import resource="../flow-beans.xml"/> 

거기에 빈이 많이있는 경우 각 플로우 인스턴스마다 복제됩니다. 일반적으로 콩을 모두 복제하여 사용자 세션에 저장하는 것을 원하지는 않습니다.

flow-beans.xml에서 싱글 톤 빈을 제거하고 일반 응용 프로그램 컨텍스트에 넣으면 여전히 플로우 정의 내에서 참조 할 수 있습니다. 또는 응용 프로그램 시작시로드 된 파일 목록에 flow-beans.xml을 추가하면됩니다.