You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by gl...@apache.org on 2003/01/26 19:55:51 UTC

cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler Compiler.java

glenn       2003/01/26 10:55:51

  Modified:    jasper2/src/share/org/apache/jasper/compiler Tag:
                        tomcat_4_branch 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
  No                   revision
  
  
  No                   revision
  
  
  1.18.2.10 +26 -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.18.2.9
  retrieving revision 1.18.2.10
  diff -u -r1.18.2.9 -r1.18.2.10
  --- Compiler.java	31 Dec 2002 14:00:36 -0000	1.18.2.9
  +++ Compiler.java	26 Jan 2003 18:55:51 -0000	1.18.2.10
  @@ -140,13 +140,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();
           // XXX We should use a specialized logger to redirect to jasperlog
  @@ -237,6 +241,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);
       }
   
       /** 
  @@ -353,8 +361,20 @@
       public void compile()
           throws FileNotFoundException, JasperException, Exception
       {
  -        generateJava();
  -        generateClass();
  +        try {
  +            generateJava();
  +            generateClass();
  +        } finally {
  +            // 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.
  +            errDispatcher = null;
  +            logger = null;
  +            project = null;
  +            pageInfo = null;
  +            pageNodes = null;
  +        }
       }
   
       /**
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>