tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 43878] New: - Tag-file classes get loaded for each JSP -> perm gen space problem
Date Fri, 16 Nov 2007 09:20:38 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=43878>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=43878

           Summary: Tag-file classes get loaded for each JSP -> perm gen
                    space problem
           Product: Tomcat 6
           Version: 6.0.10
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Jasper
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: c.korn@codekultur.de


If you use the same tag (defined in a JSP 2.0 tag file) on two different JSPs,
the tag-class will get loaded from two different classloaders resulting in two
loaded classes in the perm gen space. You can trace this behaviour when starting
the VM with the arguments "-XX:+TraceClassLoading -XX:+TraceClassUnloading". The
classes get loaded multiple times even when development/reloading is disabled.

This behaviour gets a problem if you have a huge number of JSPs (in our case
>10.000) and a few tags used on every single JSP.

I traced down the problem in the source code:

For each JSP to compile, a new instance of a JspCompilationContext is used. The
JspCompilationContext holds a reference to a JasperLoader (a ClassLoader), which
initially is null (a new JasperLoader will be created when it is first used).
The JspCompilationContext will not only load the JSP class, but also compiles
and loads tag-files referenced within the JSP. As the JasperLoader loads all
classes starting with "org.apache.jsp" by itself and does not delegate to it's
parent, the tag class (which lies underneath this package) will get loaded via
multiple JasperLoader instances.

I perfectly understand that loading each JSP via a different classloader may be
necessary, when reloading is enabled, but if reloading/development is disabled,
the same JasperLoader instance could be used. This would prevent the tag class
to get loaded multiple times. (I.e. a previously used JasperLoader instance
could be passed to the JspCompilationContext, if running in production mode).

By the way I think that loading the tag file via the same classloader as the JSP
in a reloading-enviornmane may result in some strange behaviour: If two JSPs use
the same tag and you change the tag as well as one JSP, you'll see the new
version of the tag on the reloaded JSP, but the previous version of the same tag
(but loaded via a different class-instance) on the unchanged JSP. But to solve
this issue, some greater refactoring would be necessary, I think....

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message