5 Replies Latest reply on May 13, 2010 10:13 AM by ilya_shaikovsky

    Java Out of Memory Exception

    vijayrajan1980

      Hi,

       

      address.JPG

       

      We have created a page which contains address fields where the zip/city/county are populated using rich:suggestion box.  We have 5 address tabs, which are rendered true or false base on an option the user selects.  We have around 5 X 3 (5 tabs and 3 controls on each tab) that use rich suggestion box.  Intermittently we are getting the following error when we proceed from this page.

       

      java.lang.OutOfMemoryError: Java heap space
          at org.ajax4jsf.io.CharBuffer.<init>(CharBuffer.java:59)
          at org.ajax4jsf.io.CharBuffer.append(CharBuffer.java:120)
          at org.ajax4jsf.io.FastBufferWriter.write(FastBufferWriter.java:110)
          at org.ajax4jsf.webapp.FilterServletResponseWrapper$ServletStringWriter.write(FilterServletResponseWrapper.java:317)
          at java.io.Writer.write(Writer.java:150)
          at java.io.PrintWriter.write(PrintWriter.java:384)
          at java.io.PrintWriter.write(PrintWriter.java:401)
          at org.apache.myfaces.shared_impl.renderkit.html.HtmlResponseWriterImpl.write(HtmlResponseWriterImpl.java:578)
          at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:632)
          at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100)
          at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176)
          at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:41)
          at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:140)
          at javax.faces.webapp.FacesServlet.service(FacesServlet.java:155)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
          at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
          at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
          at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378)
          at org.springframework.security.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)
          at org.springframework.security.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
          at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
          at org.springframework.security.ui.ExceptionTranslationFilter.doFilterHttp(ExceptionTranslationFilter.java:101)
          at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
          at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
          at org.springframework.security.ui.AbstractProcessingFilter.doFilterHttp(AbstractProcessingFilter.java:278)
          at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
          at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)

       

       

      Sample of rich suggestion box

       

      <rich:suggestionbox suggestionAction="#{addrBean.suggestForZip}" var="addr" eventsQueue="testQueue" for="form:Physical_zip" width="200"  height="100" fetchValue="#{addr.postalCode}" minChars="0" requestDelay="1000" nothingLabel="Invalid Zipcode"  onobjectchange="processForZip(suggestion,'form:Physical_city','form:Physical_cntyNm','form:Physical_cnty','form:Physical_jur')"   usingSuggestObjects="true" status="FunctionNameProcessing" >

                      <h:column>#{addr.postalCode}-#{addr.city}-#{addr.county}</h:column>

      </rich:suggestionbox> 

       

       

      Getting this error on tomcat 6 as well as websphere 7.0

       

       

      Can somebody help

        • 1. Re: Java Out of Memory Exception
          nbelaevski

          Hi Vijay,

           

          What is JVM heap setting you use? What is typical rendered response (HTML page) size? 

          1 of 1 people found this helpful
          • 2. Re: Java Out of Memory Exception
            vijayrajan1980

            The heap size is default, but the page size is something that is difficult to believe, it shows up as 4.5 mb on the firebug plugin.

            Maybe we are doing things wrong.  Can you suggest some way to optimize.  We have about lot of components on the page.  Lot of them dynamic and they are rendered based on user selection.   We use the following to attain the dynamic nature

             

            <rich:tabPanel  rendered="#{not empty customerEntry.characteristicsList}" switchType="client">
                            <c:forEach items="#{customerEntry.characteristicsList}" var="characteristics">
                                <rich:tab rendered="#{characteristics.rendered}">

                                     ................

                                </rich:tab>

                           </c:forEach

            </rich:tabPanel>

             

            One thing. The Out of memory exception does not come when we dont use rich:suggestion.

            • 3. Re: Java Out of Memory Exception
              ilya_shaikovsky

              at first define state saving mode in web.xml as "server"

              • 4. Re: Java Out of Memory Exception
                vijayrajan1980

                Brilliant!!!

                 

                Now the Html size is 134kb.  Need to monitor if I still get the Out of memory exception, but I doubt if I will get it now.

                 

                Thanks a lot!!!

                • 5. Re: Java Out of Memory Exception
                  ilya_shaikovsky

                  if you pages contains numerous forms - JSF view state hidden inputs will make your pages to have really huge size.

                  1 of 1 people found this helpful