You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by "Pfau, Oliver" <ol...@siemens.com> on 2007/05/14 10:29:25 UTC

JSF, Tomcat memory usage

Hi,

I have made some test with my JSF portlet regarding memory consumption
with liferay and tomcat. The memory usage increases up to 1,1 Gbyte.
After closing the session and waiting, the memory usage does not
decrease.
In detail I store a big PDF as byte[] in the session, show it and remove
it from the session but the memory usage remains on the highest value.
That's strange I think.


T:tree + facelets + portlets = not working?

Posted by "Nebinger, David" <dn...@tbbgl.com>.
I've got what I think is a pretty simple xhtml page, more or less the
intent is to have an explorer type view with a tree on the left and a
display area on the right (the display area changes depending upon the
item that gets chosen from the tree).

The items in the tree have a simple numeric identifier starting with
zero (but stored in the node as a String).

In the page below, when I click on an item in the tree the submit takes
place but my nodeSelected method never gets called.  In the display area
I hacked up a sample link to ensure that things were kosher as far as
the link is concerned, and it works.  I viewed the source of the
generated page, and the javascript is a mirror copy of what is in the
tree vs. in the link directly (except for the different element id).

I tried debugging through the code but could not find out why the action
method isn't getting called, and there are no exceptions or warnings or
anything in the log file to help me resolve the problem.

Can anyone offer some clues as to how I might get this to work?

Thanks!

viewTree.xhtml:

<f:view xmlns="http://www.w3.org/1999/xhtml"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:c="http://java.sun.com/jstl/core"
  xmlns:t="http://myfaces.apache.org/tomahawk">

<h:form >
  <h:panelGrid columns="2" columnClasses="tbb-list-col-left">
    <h:panelGroup>
      <!-- *** TREE COMPONENT *** -->
      <t:tree2 id="treeComp" value="#{navTree.tree}"
clientSideToggle="true" varNodeToggler="t" var="node"
imageLocation="/images" binding="#{navTree.htmlTree}" >
        <f:facet name="category">
          <h:panelGrid id="a" columns="2" cellpadding="0"
cellspacing="0">
            <t:graphicImage value="/images/yellow-folder-open.png"
rendered="#{t.nodeExpanded}" />
            <t:graphicImage value="/images/yellow-folder-closed.png"
rendered="#{!t.nodeExpanded}" />
            <h:outputText value="#{node.description}"
styleClass="nodeFolder" />
          </h:panelGrid>
        </f:facet>
        <f:facet name="item">
          <h:panelGroup>
            <h:commandLink styleClass="#{t.nodeSelected ?
'documentSelected':'document'}" action="#{navTree.nodeSelected}"
immediate="true">
              <h:panelGrid id="b" columns="2" cellpadding="0"
cellspacing="0">
                <t:graphicImage value="/images/document.png" />
                <h:outputText value="#{node.description}" />
              </h:panelGrid>
              <f:param name="docNum" value="#{node.identifier}" />
            </h:commandLink>
          </h:panelGroup>
        </f:facet>
      </t:tree2>
      <!-- *** END OF TREE COMPONENT *** -->
    </h:panelGroup>
    <h:panelGrid columns="1" cellpadding="10">
      <h:outputText value="Display Area" />
      <h:commandLink actionListener="#{navTree.nodeSelected}"
value="Test Link">
        <f:param name="docNum" value="0" />
      </h:commandLink>
    </h:panelGrid>
  </h:panelGrid>
  <h:messages />
</h:form>
</f:view>

The backing bean has a pretty simple nodeSelected() method:

	public String nodeSelected() {
		logger.info("*** In nodeSelected ***");

		FacesContext ctx = FacesContext.getCurrentInstance();
		Map map =
ctx.getExternalContext().getRequestParameterMap();

		String nodeId = (String) map.get("docNum");

		if ((nodeId == null) || (nodeId.trim().length() < 1)) {
			logger.error("Invalid node id from incoming
command link.");
		} else {
			logger.info("Have selected node id with value ["
+ nodeId + "].");

			if ("0".equals(nodeId)) {
				return NavigationKeys.NAV_VIEW_ROLES;
			}
			if ("1".equals(nodeId)) {
				return NavigationKeys.NAV_VIEW_GROUPS;
			}
			if ("2".equals(nodeId)) {
				return NavigationKeys.NAV_VIEW_USERS;
			}
			if ("3".equals(nodeId)) {
				return
NavigationKeys.NAV_VIEW_INACTIVE_USERS;
			}
		}

		return null;
	}

RE: JSF, Tomcat memory usage

Posted by "Cooper, Stephen" <St...@McKesson.com>.
Try instead computing the PDF byte[] from the non-portlet JSP or
servlet.  That way it should never survive Eden and get GC'ed
immediately.

  _____  

From: Pfau, Oliver [mailto:oliver.pfau@siemens.com] 
Sent: Tuesday, May 15, 2007 1:21 AM
To: MyFaces Discussion
Subject: AW: JSF, Tomcat memory usage


I set the object from a portlet and open the PDF byte[] in a non-portlet
jsp. The only way it worked by now was to set the object in portlet
application scope and read it in the jsp with session.getAttribute(...)

  _____  

Von: eric.jung@novartis.com [mailto:eric.jung@novartis.com] 
Gesendet: Montag, 14. Mai 2007 17:45
An: MyFaces Discussion
Betreff: Re: JSF, Tomcat memory usage



Why are you storing such a large object in session scope in the first
place? What's wrong with a different scope? 





"Andrew Robinson" <an...@gmail.com> 


05/14/2007 10:52 AM 


Please respond to
"MyFaces Discussion" <us...@myfaces.apache.org>



To
"MyFaces Discussion" <us...@myfaces.apache.org> 

cc

Subject
Re: JSF, Tomcat memory usage	

		




The memory will not go away until the GC decides to clean up the
objects. You may want to try to force a GC for testing reasons and see
if that shows that it is working fine (then you can remove the call to
GC as you should never call it directly)

On 5/14/07, Pfau, Oliver <ol...@siemens.com> wrote:
> Hi,
>
> I have made some test with my JSF portlet regarding memory consumption
> with liferay and tomcat. The memory usage increases up to 1,1 Gbyte.
> After closing the session and waiting, the memory usage does not
> decrease.
> In detail I store a big PDF as byte[] in the session, show it and
remove
> it from the session but the memory usage remains on the highest value.
> That's strange I think.
>
>


_________________________

CONFIDENTIALITY NOTICE

The information contained in this e-mail message is intended only for
the exclusive use of the individual or entity named above and may
contain information that is privileged, confidential or exempt from
disclosure under applicable law. If the reader of this message is not
the intended recipient, or the employee or agent responsible for
delivery of the message to the intended recipient, you are hereby
notified that any dissemination, distribution or copying of this
communication is strictly prohibited. If you have received this
communication in error, please notify the sender immediately by e-mail
and delete the material from any computer.  Thank you.


Re: AW: JSF, Tomcat memory usage

Posted by Scott O'Bryan <da...@gmail.com>.
Oliver, it will get cleaned up when the VM needs the memory.  Provided, 
of course, that you drop the element.  One thing I may suggest is a 
local filesystem cache so you don't have to store these huge objects in 
memory for the lifetime of the session.  The session is a long-lived 
object.  Even closing the browser, the session will typically hang 
around for an hour or more and not allow the vm to perform a garbage 
collection because the session may not be closed.  If you store an 
reference to the file in a disk cache and implement a Session binding 
listener, you could delete the file when the session goes away, but in 
the mean time only a small amount of your memory is actually taken up by 
this file.

Scott

Pfau, Oliver wrote:
> I set the object from a portlet and open the PDF byte[] in a 
> non-portlet jsp. The only way it worked by now was to set the object 
> in portlet application scope and read it in the jsp with 
> session.getAttribute(...)
>
> ------------------------------------------------------------------------
> *Von:* eric.jung@novartis.com [mailto:eric.jung@novartis.com]
> *Gesendet:* Montag, 14. Mai 2007 17:45
> *An:* MyFaces Discussion
> *Betreff:* Re: JSF, Tomcat memory usage
>
>
> Why are you storing such a large object in session scope in the first 
> place? What's wrong with a different scope?
>
>
>
>
> *"Andrew Robinson" <an...@gmail.com>*
>
> 05/14/2007 10:52 AM
> Please respond to
> "MyFaces Discussion" <us...@myfaces.apache.org>
>
>
> 	
> To
> 	"MyFaces Discussion" <us...@myfaces.apache.org>
> cc
> 	
> Subject
> 	Re: JSF, Tomcat memory usage
>
>
>
> 	
>
>
>
>
>
> The memory will not go away until the GC decides to clean up the
> objects. You may want to try to force a GC for testing reasons and see
> if that shows that it is working fine (then you can remove the call to
> GC as you should never call it directly)
>
> On 5/14/07, Pfau, Oliver <ol...@siemens.com> wrote:
> > Hi,
> >
> > I have made some test with my JSF portlet regarding memory consumption
> > with liferay and tomcat. The memory usage increases up to 1,1 Gbyte.
> > After closing the session and waiting, the memory usage does not
> > decrease.
> > In detail I store a big PDF as byte[] in the session, show it and remove
> > it from the session but the memory usage remains on the highest value.
> > That's strange I think.
> >
> >
>
>
> _________________________
>
> CONFIDENTIALITY NOTICE
>
> The information contained in this e-mail message is intended only for 
> the exclusive use of the individual or entity named above and may 
> contain information that is privileged, confidential or exempt from 
> disclosure under applicable law. If the reader of this message is not 
> the intended recipient, or the employee or agent responsible for 
> delivery of the message to the intended recipient, you are hereby 
> notified that any dissemination, distribution or copying of this 
> communication is strictly prohibited. If you have received this 
> communication in error, please notify the sender immediately by e-mail 
> and delete the material from any computer.  Thank you.


AW: JSF, Tomcat memory usage

Posted by "Pfau, Oliver" <ol...@siemens.com>.
I set the object from a portlet and open the PDF byte[] in a non-portlet
jsp. The only way it worked by now was to set the object in portlet
application scope and read it in the jsp with session.getAttribute(...)

________________________________

Von: eric.jung@novartis.com [mailto:eric.jung@novartis.com] 
Gesendet: Montag, 14. Mai 2007 17:45
An: MyFaces Discussion
Betreff: Re: JSF, Tomcat memory usage



Why are you storing such a large object in session scope in the first
place? What's wrong with a different scope? 





"Andrew Robinson" <an...@gmail.com> 

05/14/2007 10:52 AM 
Please respond to
"MyFaces Discussion" <us...@myfaces.apache.org>


To
"MyFaces Discussion" <us...@myfaces.apache.org> 
cc
Subject
Re: JSF, Tomcat memory usage

	




The memory will not go away until the GC decides to clean up the
objects. You may want to try to force a GC for testing reasons and see
if that shows that it is working fine (then you can remove the call to
GC as you should never call it directly)

On 5/14/07, Pfau, Oliver <ol...@siemens.com> wrote:
> Hi,
>
> I have made some test with my JSF portlet regarding memory consumption
> with liferay and tomcat. The memory usage increases up to 1,1 Gbyte.
> After closing the session and waiting, the memory usage does not
> decrease.
> In detail I store a big PDF as byte[] in the session, show it and
remove
> it from the session but the memory usage remains on the highest value.
> That's strange I think.
>
>


_________________________

CONFIDENTIALITY NOTICE

The information contained in this e-mail message is intended only for
the exclusive use of the individual or entity named above and may
contain information that is privileged, confidential or exempt from
disclosure under applicable law. If the reader of this message is not
the intended recipient, or the employee or agent responsible for
delivery of the message to the intended recipient, you are hereby
notified that any dissemination, distribution or copying of this
communication is strictly prohibited. If you have received this
communication in error, please notify the sender immediately by e-mail
and delete the material from any computer.  Thank you.


Re: JSF, Tomcat memory usage

Posted by er...@novartis.com.
Why are you storing such a large object in session scope in the first 
place? What's wrong with a different scope?





"Andrew Robinson" <an...@gmail.com> 
05/14/2007 10:52 AM
Please respond to
"MyFaces Discussion" <us...@myfaces.apache.org>


To
"MyFaces Discussion" <us...@myfaces.apache.org>
cc

Subject
Re: JSF, Tomcat memory usage






The memory will not go away until the GC decides to clean up the
objects. You may want to try to force a GC for testing reasons and see
if that shows that it is working fine (then you can remove the call to
GC as you should never call it directly)

On 5/14/07, Pfau, Oliver <ol...@siemens.com> wrote:
> Hi,
>
> I have made some test with my JSF portlet regarding memory consumption
> with liferay and tomcat. The memory usage increases up to 1,1 Gbyte.
> After closing the session and waiting, the memory usage does not
> decrease.
> In detail I store a big PDF as byte[] in the session, show it and remove
> it from the session but the memory usage remains on the highest value.
> That's strange I think.
>
>


_________________________

CONFIDENTIALITY NOTICE

The information contained in this e-mail message is intended only for the 
exclusive use of the individual or entity named above and may contain 
information that is privileged, confidential or exempt from disclosure 
under applicable law. If the reader of this message is not the intended 
recipient, or the employee or agent responsible for delivery of the 
message to the intended recipient, you are hereby notified that any 
dissemination, distribution or copying of this communication is strictly 
prohibited. If you have received this communication in error, please 
notify the sender immediately by e-mail and delete the material from any 
computer.  Thank you.

Re: JSF, Tomcat memory usage

Posted by Andrew Robinson <an...@gmail.com>.
The memory will not go away until the GC decides to clean up the
objects. You may want to try to force a GC for testing reasons and see
if that shows that it is working fine (then you can remove the call to
GC as you should never call it directly)

On 5/14/07, Pfau, Oliver <ol...@siemens.com> wrote:
> Hi,
>
> I have made some test with my JSF portlet regarding memory consumption
> with liferay and tomcat. The memory usage increases up to 1,1 Gbyte.
> After closing the session and waiting, the memory usage does not
> decrease.
> In detail I store a big PDF as byte[] in the session, show it and remove
> it from the session but the memory usage remains on the highest value.
> That's strange I think.
>
>