Announcement Announcement Module
No announcement yet.
problem use aop lead to using too much memory Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • problem use aop lead to using too much memory

    I develope a j2ee project using struts,spring and hibernate. I use aop to manage transaction. I defined 50 pointcuts and advisors. after I finished this, I startup my project in tomcat , I find using 1G memory! I'm surprising!
    I disable all of aop configurations , startup my project again, then only using
    300M memory!

    my service class that are configured with aop all implement interface ,then using spring jdk proxy! why using too much memory!

    I defined pointcuts using AspectJ pointcut language ,like :
    <aopointcut id="pointcut1" expression="execution{* com.myproject.service.*.*(..)}"/>
    <aop:advisor id="advisor1" pointcut-ref="pointcut1" advice-ref="aop_advice"/>

    <tx:advice id="aop_advice" transaction-manager="transactionManager">
    <tx:method name="insert*" read-only="true" propagation="REQUIRED" />
    <tx:method name="find*" read-only="true" propagation="REQUIRED" />
    <tx:method name="*" propagation="REQUIRED" />

    why aop lead to using much memory?

  • #2
    Just guessing isn't going to work. My guess to much proxies are created due to messy configuration. Could you post the relevant configuration and please use [ code][/code ] tags when doing so.


    • #3
      Pointcuts like these will lead to many, many joinpoints being advised:
      <aopointcut id="pointcut1" expression="execution{* com.myproject.service.*.*(..)}"/>

      This means every method in the service package will be advised. Doing LTW on this will force a proxy on every class in that package. Do this for a few packages, and you will have a much bigger footprint.

      If memory is an issue, I would consider moving to AspectJ compile time weaving and avoid the use of creating any proxies at all.

      As Marten says, it also may be worth taking a look at your configuration.


      • #4
        thank you for anwser my question.
        but I couldn't show the relevant configuration for project's security.
        aop configuration in my project using another define transaction of spring1.X ,like following:
        [ code]
        <bean id="transactionInterceptor"
        class="org.springframework.transaction.interceptor .TransactionInterceptor">
        <property name="transactionManager" ref="transactionManager"/>
        <property name="transactionAttributes">
        <prop key="insert*">PROPAGATION_REQUIRED</prop>
        <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
        <prop key="*">PROPAGATION_REQUIRED</prop>

        <bean class="org.springframework.aop.framework.autoproxy .BeanNameAutoProxyCreator">
        <property name="beanNames">
        <property name="interceptorNames">
        [/code ]

        I use above mothed to confugure aop ,then memory is small. I get the snapshot of jvm's heap in using AspectJ pointcut language , I find much objects created belonged to org.aspectj.*. but jvm couldn't collect these objects.


        • #5
          First off all you are doubling the amount of proxies created by mixing 2 different strategies, next to that it isn't adviced that you use 2 different proxing mechanisms.