[jboss-user] [JBoss Seam] - WebSessionContext.flush causing out of memory

jarkko@jab.fi do-not-reply at jboss.com
Thu Oct 12 21:09:21 EDT 2006


Hello,
 A  change (from non impl to the current copy-all) in WebSessionContext.flush is causing out-of-memory experiance in my portlet environment (with the special naive PortletSessionImpl). 
With the flush below, 1000 Mb of memory consumed in 20 clicks in seam app, with the flush commented out no problem.
 This is likely caused by the PortletSessionImpl which simply sets everything both in APPLICATION and PORTLET scope..  Btw i used the Jhat (included with JDK6) too to track this one down, pretty neat tool, now that's included with the JDK6. http://weblogs.java.net/blog/jfarcand/archive/2006/02/using_mustangs.html

The names of attributes were very very long: 
javax.portlet.p.tc3_konseptimittaus_WAR_TrueConcept_LAYOUT_PRI.1005.6?javax.portlet.p.tc3Portlet_kohteen_valinta_WAR_TrueConcept_LAYOUT_PRI.1005.6?javax.portlet.p.tc3Portlet_kohteen_valinta_WAR_TrueConcept_LAYOUT_PRI.1005.6?javax.portlet.p.tc3_konseptimittaus_WAR_TrueConcept_LAYOUT_PRI.1005.6?javax.portlet.p.tc3Portlet_kohteen_valinta_WAR_TrueConcept_LAYOUT_PRI.1005.6?javax.portlet.p.tc3_konseptimittaus_WAR_TrueConcept_LAYOUT_PRI.1005.6?javax.portlet.p.tc3Portlet_kohteen_valinta_WAR_TrueConcept_LAYOUT_PRI.1005.6?javax.portlet.p.tc3Portlet_kohteen_valinta_WAR_TrueConcept_LAYOUT_PRI.1005.6?javax.portlet.p.tc3_konseptimittaus_WAR_TrueConcept_LAYOUT_PRI.1005.6?javax.portlet.p.tc3Portlet_kohteen_valinta_WAR_TrueConcept_LAYOUT_PRI.1005.6?javax.portlet.p.tc3Portlet_kohteen_valinta_WAR_TrueConcept_LAYOUT_PRI.1005.6?javax.portlet.p.tc3_konseptimittaus_WAR_TrueConcept_LAYOUT_PRI.1005.6?javax.portlet.p.tc3Portlet_kohteen_valinta_WAR_TrueConcept_LAYOUT_PRI.1005.6?javax.portlet.p.tc3_konseptimittaus_WAR_TrueConcept_LAYOUT_PRI.1005.6?javax.portlet.p.tc3_konseptimittaus_WAR_TrueConcept_LAYOUT_PRI.1005.6?javax.portlet.p.tc3Portlet_kohteen_valinta_WAR_TrueConcept_LAYOUT_PRI.1005.6?javax.portlet.p.tc3Portlet_kohteen_valinta_WAR_TrueConcept_LAYOUT_PRI.1005.6?javax.portlet.p.tc3_konseptimittaus_WAR_TrueConcept_LAYOUT_PRI.1005.6?javax.portlet.p.tc3Portlet_kohteen_valinta_WAR_TrueConcept_LAYOUT_PRI.1005.6?javax.portlet.p.tc3Portlet_kohteen_valinta_WAR_TrueConcept_LAYOUT_PRI.1005.6?javax.portlet.p.tc3Portlet_kohteen_valinta_WAR_TrueConcept_LAYOUT_PRI.1005.6?org.jboss.seam.CONVERSATION#3$tc3EntityManager
This might indicate that there're some pretty weird namespace related problems when running on Portlets.


   
  | public void flush() {
  |       for ( String name: getNames() )
  |       {
  |          Object attribute = session.getAttribute(name);
  |          if ( attribute instanceof Mutable && ( (Mutable) attribute ).clearDirty() )
  |          {
  |             session.setAttribute(name, attribute);
  |          }
  |       }      
  | 


  | /*
  |  * JBoss, Home of Professional Open Source
  |  *
  |  * Distributable under LGPL license.
  |  * See terms of license at gnu.org.
  |  */
  | package org.jboss.seam.portlet;
  | 
  | import java.util.Collections;
  | import java.util.Enumeration;
  | import java.util.List;
  | 
  | import javax.portlet.PortletSession;
  | 
  | import org.apache.commons.collections.ListUtils;
  | import org.jboss.seam.contexts.ContextAdaptor;
  | 
  | /**
  |  * @author <a href="mailto:theute at jboss.org">Thomas Heute </a>
  |  * @version $Revision: 1.4 $
  |  */
  | public class PortletSessionImpl extends ContextAdaptor {
  | 
  | 	private PortletSession session;
  | 
  | 	public PortletSessionImpl(PortletSession session) {
  | 		this.session = session;
  | 	}
  | 
  | 	public Object getAttribute(String key) {
  | 		// search for key first in PORTLET_SCOPE
  | 		Object o = session.getAttribute(key);
  | 		Object po = null;
  | 		// if nothing is found there try APPLICATION_SCOPE
  | 		if (o == null) {
  | 			po = session.getAttribute(key, PortletSession.APPLICATION_SCOPE);
  | 			return po;
  | 		} else {
  | 			// TODO: just do some cleaning up or maybe not
  | 			// session.removeAttribute(key, PortletSession.APPLICATION_SCOPE);
  | 		}
  | 
  | 		return o;
  | 	}
  | 
  | 	public void removeAttribute(String key) {
  | 		session.removeAttribute(key);
  | 		session.removeAttribute(key, PortletSession.APPLICATION_SCOPE);
  | 	}
  | 
  | 	public Enumeration getAttributeNames() {
  | 		Enumeration portletAttributeNamesEnum = session.getAttributeNames();
  | 		Enumeration portalAttributeNamesEnum = session
  | 				.getAttributeNames(PortletSession.APPLICATION_SCOPE);
  | 
  | 		List portletAttributeNames = Collections
  | 				.list(portletAttributeNamesEnum);
  | 		List portalAttributeNames = Collections.list(portalAttributeNamesEnum);
  | 
  | 		// TODO: Is this correct?
  | 		List allNames = ListUtils.sum(portletAttributeNames,
  | 				portalAttributeNames);
  | 
  | 		return Collections.enumeration(allNames);
  | 	}
  | 
  | 	public void setAttribute(String key, Object value) {
  | 		session.setAttribute(key, value);
  | 		session.setAttribute(key, value, PortletSession.APPLICATION_SCOPE);
  | 	}
  | 
  | 	public void invalidate() {
  | 		session.invalidate();
  | 	}
  | 
  | }
  | 
  | 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3978047#3978047

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3978047




More information about the jboss-user mailing list