Search code examples
grailsgrails-ormhibernate-mapping

GORM/Hibernate + GC overhead limit exceeded


The following remove() method is causing "GC overhead limit exceeded." when deleting the associations present in ABC from either of A or B or C. Can you please advise what is wrong? NOTE - ABC is the mapping table for A,B,C

The stacktrace is as follows: Caused by: java.lang.OutOfMemoryError: GC overhead limit exceeded at java.util.jar.Attributes.read(Attributes.java:394) at java.util.jar.Manifest.read(Manifest.java:199) at java.util.jar.Manifest.<init>(Manifest.java:69) at java.util.jar.JarFile.getManifestFromReference(JarFile.java:185) at java.util.jar.JarFile.getManifest(JarFile.java:166) at java.net.URLClassLoader.defineClass(URLClassLoader.java:416) at java.net.URLClassLoader.access$100(URLClassLoader.java:71) at java.net.URLClassLoader$1.run(URLClassLoader.java:361) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at org.codehaus.groovy.tools.RootLoader.oldFindClass(RootLoader.java:171) at org.codehaus.groovy.tools.RootLoader.loadClass(RootLoader.java:143) at java.lang.ClassLoader.loadClass(ClassLoader.java:358)

@Resource() 
@EqualsAndHashCode 
class ABC {
    static belongsTo = 
        [
            a: A, 
            b: B, 
            c: C
        ]

    def remove(){
        this.a?.removeFromBC(this)
        this.b?.removeFromAC(this)
        this.c?.removeFromAB(this)
        this.delete()
    }

@Resource()
class C {
    Collection<ABC> aB
    static hasMany = [aB: ABC]
    static constraints = {
        aB cascade: "all-delete-orphan", nullable: true
    }
}

@Resource()
class B {
    Collection<ABC> aC
    static hasMany = [aC: ABC]
    static constraints = {
        aC cascade: "all-delete-orphan", nullable: true
    }
}

@Resource()
class A {
    Collection<ABC> bC
    static hasMany = [bC: ABC]
    static constraints = {
        bC cascade: "all-delete-orphan", nullable: true
    }
}

Solution

  • No, that method is not triggering an OOME, running with too little heap space allocated is. Increase the memory for your server.