Debugging issues with a bunch of space in a Groovy / Grails application using quartz

I created a small application in Groovy / Grails that uses Quartz to do a small job every 10 seconds. Now I have a problem that after several hours of work, the application crashes with org.quartz.JobExecutionException: java.lang.OutOfMemoryError: Java heap space [See nested exception: java.lang.OutOfMemoryError: Java heap space].

Now I am trying to find the cause of this problem using Eclipse Memory Analyzer . Finding the "problem suspects", the analyzer shows this result:

Problem Suspect 1

3,926 instances of "groovy.lang.ExpandoMetaClass",
loaded by "org.codehaus.groovy.grails.cli.support.GrailsRootLoader @ 0x122e88b98" 
occupy 95,746,168 (33.69%) bytes. 

Keywords
org.codehaus.groovy.grails.cli.support.GrailsRootLoader @ 0x122e88b98
groovy.lang.ExpandoMetaClass

--    

Problem Suspect 2

1,010 instances of "com.mongodb.DBApiLayer",
loaded by "org.codehaus.groovy.grails.cli.support.GrailsRootLoader @ 0x122e88b98" 
occupy 56,522,416 (19.89%) bytes.
These instances are referenced from one instance of
"org.codehaus.groovy.util.AbstractConcurrentMapBase$Segment[]", loaded by 
"org.codehaus.groovy.grails.cli.support.GrailsRootLoader @ 0x122e88b98"

Keywords
org.codehaus.groovy.grails.cli.support.GrailsRootLoader @ 0x122e88b98
org.codehaus.groovy.util.AbstractConcurrentMapBase$Segment[]
com.mongodb.DBApiLayer

Is it normal to have many instances ExpandoMetaClassin a Groovy (and Grails) application, or maybe there is a problem that I presented?

MongoDB: GORM Gmongo. , , . 40. , . , . ?

?

+4
2

@jonnybot , GMongo, . GMongo, , - MongoDB, . :

class MemoryJob {
    def concurrent = false
    static triggers = {
        simple startDelay: 5000, repeatInterval: 1000
    }
    def execute() {
        def mongoUrl = "mongodb://localhost:27017"
        def mongo = new GMongo(new MongoURI(mongoUrl))
        def db = mongo.getDB("memory")
        println new Date()
        db.getCollection("test").insert(['date':new Date()])
        mongo.close()
    }
}

GMongo . :

class MemoryJob {
    def concurrent = false
    static triggers = {
        simple startDelay: 5000, repeatInterval: 200
    }
    static mongoUrl = "mongodb://localhost:27017"
    static mongo = new GMongo(new MongoURI(mongoUrl))
    static db = mongo.getDB("memory");
    def execute() {
        println new Date()
        db.getCollection("test").insert(['date':new Date()])
    }
}

, , .

. MongoDB , . , , GMongo .

, - .

+1

GMongo. gmongo Github, .

Gmongo - , grails mongo (. ).

, MongoDB Gmongo Grails, .

; , .

export GRAILS_OPTS="-Xmx1G -Xms256m -XX:MaxPermSize=256m"
grails run-app

, . , , . , gmongo.

+1

All Articles