glenn 2003/01/26 11:00:58 Modified: jasper2/src/share/org/apache/jasper/compiler Compiler.java Log: Dereference those objects which are only used during the generation of the java class from the JSP source or used during the javac compile. This should reduce the memory footprint of Tomcat in production for those who use JSP and where JSP pages get compiled or recompiled on a production system. This should also improve performance by reducing the number of objects in the old generation, thus reducing GC overhead. Revision Changes Path 1.47 +27 -6 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Compiler.java Index: Compiler.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Compiler.java,v retrieving revision 1.46 retrieving revision 1.47 diff -u -r1.46 -r1.47 --- Compiler.java 22 Jan 2003 20:39:28 -0000 1.46 +++ Compiler.java 26 Jan 2003 19:00:58 -0000 1.47 @@ -137,13 +137,17 @@ public Compiler(JspCompilationContext ctxt, JspServletWrapper jsw) { this.jsw = jsw; this.ctxt = ctxt; - this.errDispatcher = new ErrorDispatcher(); this.options = ctxt.getOptions(); } // Lazy eval - if we don't need to compile we probably don't need the project private Project getProject() { + + if (errDispatcher == null) { + this.errDispatcher = new ErrorDispatcher(); + } if( project!=null ) return project; + // Initializing project project = new Project(); logger = new JasperAntLogger(); @@ -275,6 +279,10 @@ // generate servlet .java file Generator.generate(writer, this, pageNodes); writer.close(); + // The writer is only used during the compile, dereference + // it in the JspCompilationContext when done to allow it + // to be GC'd and save memory. + ctxt.setWriter(null); long t4=System.currentTimeMillis(); if( t4-t1 > 500 ) { @@ -416,11 +424,24 @@ public void compile() throws FileNotFoundException, JasperException, Exception { - generateJava(); - generateClass(); - if (tfp != null) { - tfp.removeProtoTypeFiles(null); - } + try { + generateJava(); + generateClass(); + } finally { + if (tfp != null) { + tfp.removeProtoTypeFiles(null); + } + // Make sure these object which are only used during the + // generation and compilation of the JSP page get + // dereferenced so that they can be GC'd and reduce the + // memory footprint. + tfp = null; + errDispatcher = null; + logger = null; + project = null; + pageInfo = null; + pageNodes = null; + } } /**
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>