Announcement Announcement Module
Collapse
No announcement yet.
StringHTTPMessageConverter loading all charsets causing java heap jump Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • StringHTTPMessageConverter loading all charsets causing java heap jump

    Hi,

    We are having a portlet application which uses Spring 3.1.0.Final and deployed on WAS 6.1.

    We have multiple portlets using Spring MVC in past. This is the first portlet with Spring 3. I am using annotations and autowiring in most of the places in the code.

    When this application is deployed in server the base heap usage jumped by 25+ MB.

    I did profiling using Jprofiler and found that StringHTTPMessageConverter is loading all charsets in memory which occupies around 14 MB of memory (com.ibm.nio.charset.Charset takes up memory)

    Since it is a portlet app I have org.springframework.web.portlet.mvc.annotation.Ann otationMethodHandlerAdapter bean explicity defined in my configuration and not org.springframework.web.servlet.mvc.annotation.Ann otationMethodHandlerAdapter

    This is what I have tried doing so far

    1) Change StringHttpMessageConvertor settings

    Defined the following bean in my configuration

    <bean class = "org.springframework.web.servlet.mvc.annotation.An notationMethodHandlerAdapter">
    <property name = "messageConverters">
    <list>
    <bean class = "org.springframework.http.converter.StringHttpMess ageConverter">
    <property name = "supportedMediaTypes">
    <list>
    text/plain;charset=UTF-8
    </list>
    </property>
    </bean>
    </list>
    </property>
    </bean>

    No luck with this.


    2) I have <mvc:annotations/> defined in my config file. As suggested in some posts I also tried the above configuration by commenting out the <mc:annotations/> tag. But no luck.


    3) As suggested in some forums I Tried to write BeanPostProcessor but it could not find the StringHttpMessageConverter class.

    Do I need to explicitly define org.springframework.web.servlet.mvc.annotation.Ann otationMethodHandlerAdapter in my configuration?

    My questions are

    1) Is there any way to avoid all charsets loading up in memory?

    2) Also Is the 25 MB jump in base heap justifiable ? What is the usual memory foot print of Spring 3.1.0 ?

    I am running out of ideas Any help regarding fine tuning the Spring framework would be highly appreciated.

    Thanks and Regards
    RaviG

  • #2
    Please use [ code][/code ] tags when posting code, that way it remains readable.

    There isn't much you can do about it as soon as the class is loaded a List of all available charsets is loaded, regardless of your configuration. So if you don't need it don't load it.

    So both 1 and 2 aren't a solution neither is defining the AnnotationMethodHandlerAdapter as that all would trigger loading the mentioed class. The mvc:Annotationtag loads the RequestMappingHandlerAdapter which is the new class, could see if that loads the aforementioned converter.

    Also why are you trying to fix this is it a problem?! If it isn't why are you trying to solve it?

    Comment


    • #3
      @Marten: Thanks for the response, I will make sure that I use code tags next time.

      I didn't understand your statement " So if you don't need it don't load it." How do I do that?

      I am trying to optimize the heap size as we have some memory issues . This charset remains in heap and is not getting GC'ed

      20-25 MB heap size is increase is observed as soon as we deploy the application. Is this normal?

      Comment


      • #4
        When I do profiling using Jprofiler I find the following. This is not getting Gc'ed

        Attachment
        Attached Files

        Comment


        • #5
          20-25 MB heap size is increase is observed as soon as we deploy the application. Is this normal?
          I have no idea if this is normal, depends on the application, what it does, etc. There is not really a general purpose answer to give here.

          I didn't understand your statement " So if you don't need it don't load it." How do I do that?
          Well make sure it doesn't load, a simple answer but it doesn't mean it is simple to achieve. The class is loaded by, at least, the servlet part which you forcefully loaded by including mvc:annotation-driven and/or AnnotationMethodHandlerAdapter. Judging from your post you are doing portlets and not servlets so you shouldn't need those.

          I couldn't find a reference to any portlet class that loads that class (directly at least).

          Comment

          Working...
          X