ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gle...@ca.ibm.com
Subject [PATCH] Less memory consumption for subbuilds
Date Tue, 18 Jul 2000 13:18:20 GMT




This is an alternative to the patch I posted on the weekend for adding
inherited property support to a project.  It acomplishes the goal of saving
memory by not copying all the parent build properties into the sub build
untill just before configuring it with ProjectHelper.  Also, the execute
method now has a try/finally block to ensure the subproject p1 is set to
null so it can be GC'ed (thanks for pointing that out Conor).

Index: jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Ant.java
===================================================================
RCS file:
/home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Ant.java,v

retrieving revision 1.10
diff -u -r1.10 Ant.java
--- jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Ant.java
2000/07/12 06:36:11        1.10
+++ jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Ant.java
2000/07/18 13:09:51
@@ -114,43 +114,49 @@
             p1.addTaskDefinition(taskName, taskClass);
         }

-        // set user-define properties
-        Hashtable prop1 = project.getProperties();
-        Enumeration e = prop1.keys();
-        while (e.hasMoreElements()) {
-            String arg = (String) e.nextElement();
-            String value = (String) prop1.get(arg);
-            p1.setProperty(arg, value);
-        }
     }

     /**
      * Do the execution.
      */
     public void execute() throws BuildException {
-        if( dir==null) dir=".";
-
-        p1.setBasedir(dir);
-        p1.setUserProperty("basedir" , dir);
-
-        // Override with local-defined properties
-        Enumeration e = properties.elements();
-        while (e.hasMoreElements()) {
-            Property p=(Property) e.nextElement();
-            //            System.out.println("Setting " + p.getName()+ " "
+ p.getValue());
-            p.init();
-        }
-
-        if (antFile == null) antFile = dir + "/build.xml";
-
-        p1.setUserProperty( "ant.file" , antFile );
-        ProjectHelper.configureProject(p1, new File(antFile));
-
-        if (target == null) {
-            target = p1.getDefaultTarget();
+        try {
+            if( dir==null) dir=".";
+
+            p1.setBasedir(dir);
+            p1.setUserProperty("basedir" , dir);
+
+            // set user-define properties
+            Hashtable prop1 = project.getProperties();
+            Enumeration e = prop1.keys();
+            while (e.hasMoreElements()) {
+                String arg = (String) e.nextElement();
+                String value = (String) prop1.get(arg);
+                p1.setProperty(arg, value);
+            }
+
+            // Override with local-defined properties
+            e = properties.elements();
+            while (e.hasMoreElements()) {
+                Property p=(Property) e.nextElement();
+                //            System.out.println("Setting " + p.getName()+
" " + p.getValue());
+                p.init();
+            }
+
+            if (antFile == null) antFile = dir + "/build.xml";
+
+            p1.setUserProperty( "ant.file" , antFile );
+            ProjectHelper.configureProject(p1, new File(antFile));
+
+            if (target == null) {
+                target = p1.getDefaultTarget();
+            }
+
+            p1.executeTarget(target);
+
+        } finally {
+            p1 = null;
         }
-
-        p1.executeTarget(target);
     }

     public void setDir(String d) {

Glenn McAllister
TID - Software Developer - VisualAge for Java
IBM Toronto Lab, (416) 448-3805
"An approximate answer to the right question is better than the
right answer to the wrong question." - John W. Tukey



Mime
View raw message