GORM/Hibernate + 超过 GC 开销限制
GORM/Hibernate + GC overhead limit exceeded
从 A 或 B 或 C 中删除 ABC 中存在的关联时,以下 remove() 方法会导致 "GC overhead limit exceeded."。请问哪里出了问题?
注意 - ABC 是 A、B、C
的映射 table
堆栈跟踪如下:
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.access0(URLClassLoader.java:71)
at java.net.URLClassLoader.run(URLClassLoader.java:361)
at java.net.URLClassLoader.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
}
}
不,该方法不会触发 OOME,运行 分配的堆 space 太少了。增加服务器的内存。
从 A 或 B 或 C 中删除 ABC 中存在的关联时,以下 remove() 方法会导致 "GC overhead limit exceeded."。请问哪里出了问题? 注意 - ABC 是 A、B、C
的映射 table堆栈跟踪如下:
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.access0(URLClassLoader.java:71)
at java.net.URLClassLoader.run(URLClassLoader.java:361)
at java.net.URLClassLoader.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
}
}
不,该方法不会触发 OOME,运行 分配的堆 space 太少了。增加服务器的内存。