Skip to content

Commit d642bcb

Browse files
author
graeme
committed
fix for memory leak when doing grails run-app (GRAILS-1550)
git-svn-id: https://svn.codehaus.org/grails/trunk@5754 1cfb16fd-6d17-0410-8ff1-b7e8e1e2867d
1 parent 7cc3c68 commit d642bcb

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

scripts/Init.groovy

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -389,35 +389,36 @@ target(classpath:"Sets the Grails classpath") {
389389
setClasspath()
390390
}
391391

392-
void setClasspath() {
393-
if (classpathSet) return
394-
395-
def grailsDir = resolveResources("file:${basedir}/grails-app/*")
396-
def pluginLibs = resolveResources("file:${basedir}/plugins/*/lib")
397-
398-
Ant.path(id:"grails.classpath") {
392+
grailsClasspath = { pluginLibs, grailsDir ->
399393
pathelement(location:"${classesDir.absolutePath}")
400394
pathelement(location:"${basedir}")
401395
pathelement(location:"${basedir}/test/unit")
402-
pathelement(location:"${basedir}/test/integration")
396+
pathelement(location:"${basedir}/test/integration")
403397
pathelement(location:"${basedir}/web-app")
404398
pathelement(location:"${basedir}/web-app/WEB-INF")
405399
pathelement(location:"${basedir}/web-app/WEB-INF/classes")
406-
for(pluginLib in pluginLibs) {
400+
for(pluginLib in pluginLibs) {
407401
fileset(dir:pluginLib.file.absolutePath)
408402
}
409403
if (new File("${basedir}/web-app/WEB-INF/lib").exists()) {
410404
fileset(dir:"${basedir}/web-app/WEB-INF/lib")
411405
}
412406
fileset(dir:"${grailsHome}/lib")
413-
fileset(dir:"${grailsHome}/dist")
407+
fileset(dir:"${grailsHome}/dist")
414408
if(new File("${basedir}/lib").exists()) {
415409
fileset(dir:"${basedir}/lib")
416410
}
417411
for(d in grailsDir) {
418412
pathelement(location:"${d.file.absolutePath}")
419413
}
420-
}
414+
}
415+
void setClasspath() {
416+
if (classpathSet) return
417+
418+
def grailsDir = resolveResources("file:${basedir}/grails-app/*")
419+
def pluginLibs = resolveResources("file:${basedir}/plugins/*/lib")
420+
421+
Ant.path(id:"grails.classpath",grailsClasspath.curry(pluginLibs, grailsDir))
421422
StringBuffer cpath = new StringBuffer("")
422423

423424
def jarFiles = getJarFiles()

scripts/RunApp.groovy

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,21 @@ target( watchContext: "Watches the WEB-INF/classes directory for changes and res
6868
long lastModified = classesDir.lastModified()
6969
while(true && autoRecompile) {
7070
try {
71-
Ant.groovyc(destdir:classesDirPath,
71+
def ant = new AntBuilder()
72+
ant.taskdef ( name : 'groovyc' ,
73+
classname : 'org.codehaus.groovy.grails.compiler.GrailsCompiler' )
74+
def grailsDir = resolveResources("file:${basedir}/grails-app/*")
75+
def pluginLibs = resolveResources("file:${basedir}/plugins/*/lib")
76+
ant.path(id:"grails.classpath",grailsClasspath.curry(pluginLibs, grailsDir))
77+
ant.groovyc(destdir:classesDirPath,
7278
classpathref:"grails.classpath",
7379
resourcePattern:"file:${basedir}/**/grails-app/**/*.groovy",
7480
projectName:baseName) {
7581
src(path:"${basedir}/src/java")
7682
src(path:"${basedir}/src/groovy")
7783
src(path:"${basedir}/grails-app/domain")
7884
}
79-
85+
ant = null
8086
}
8187
catch(Exception e) {
8288
compilationError = true
@@ -105,7 +111,7 @@ target( watchContext: "Watches the WEB-INF/classes directory for changes and res
105111
lastModified = classesDir.lastModified()
106112
}
107113
}
108-
sleep(2500)
114+
sleep(5)
109115
}
110116
}
111117

0 commit comments

Comments
 (0)