I'm trying to get the dbm-gorm-diff command from the database migration plugin running. However, I always run into a java.lang.OutOfMemoryError: PermGen space
I already tried to alter configuration for the JVM. That's my current configuration:
GGTS.ini
-vm
C:/Program Files/Java/jdk1.8.0_20/bin/javaw.exe
-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20130327-1440.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.200.v20140116-2212
-product
org.springsource.ggts.ide
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
256M
-vmargs
-Dgrails.console.enable.interactive=false
-Dgrails.console.enable.terminal=false
-Djline.terminal=jline.UnsupportedTerminal
-Dgrails.console.class=grails.build.logging.GrailsEclipseConsole
-Dosgi.requiredJavaVersion=1.6
-Xms512m
-Xmx1024m
-XX:PermSize=1024m
-XX:MaxPermSize=2G
-Dorg.eclipse.swt.browser.IEVersion=10001
BuildConfig.groovy:
grails.project.fork = [
// configure settings for compilation JVM, note that if you alter the Groovy version forked compilation is required
// compile: [maxMemory: 256, minMemory: 64, debug: false, maxPerm: 256, daemon:true],
// configure settings for the test-app JVM, uses the daemon by default
test: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 1024, daemon:true],
// configure settings for the run-app JVM
run: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 1024, forkReserve:false],
// configure settings for the run-war JVM
war: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 1024, forkReserve:false],
// configure settings for the Console UI JVM
console: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 1024]
]
I don't know if I missed a configuration file or a certain property to set. Maybe you have some advice for me?
I'm currently using jdk1.7.0_67, ggts 3.6.1 and grails 2.4.2
--- EDIT ---
maybe the stacktrace does also help:
Loading Grails 2.4.2
|Configuring classpath
.
|Environment set to development
...........................................
............
.
Configuring Spring Security Core ...
... finished configuring Spring Security Core
Configuring Spring Security UI ...
... finished configuring Spring Security UI
Configuring Spring Security Core ...
... finished configuring Spring Security Core
Configuring Spring Security UI ...
... finished configuring Spring Security UI
.
|Starting dbm-gorm-diff
Error |
java.lang.OutOfMemoryError: PermGen space
Error |
at com.sun.org.apache.xalan.internal.xsltc.runtime.output.TransletOutputHandlerFactory.getSerializationHandler(TransletOutputHandlerFactory.java:165)
Error |
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.getOutputHandler(TransformerImpl.java:454)
Error |
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:344)
Error |
at liquibase.util.xml.DefaultXmlWriter.write(DefaultXmlWriter.java:32)
Error |
at liquibase.serializer.core.xml.XMLChangeLogSerializer.write(XMLChangeLogSerializer.java:106)
Error |
at grails.plugin.databasemigration.MySQLCompatibleChangeLogSerializer.super$2$write(MySQLCompatibleChangeLogSerializer.groovy)
Error |
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Error |
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
Error |
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
Error |
at java.lang.reflect.Method.invoke(Method.java:606)
Error |
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
Error |
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
Error |
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1085)
Error |
at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1110)
Error |
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:128)
Error |
at grails.plugin.databasemigration.MySQLCompatibleChangeLogSerializer.write(MySQLCompatibleChangeLogSerializer.groovy:32)
Error |
at liquibase.diff.DiffResult.printChangeLog(DiffResult.java:507)
Error |
at liquibase.diff.DiffResult$printChangeLog$1.call(Unknown Source)
Error |
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
Error |
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
Error |
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:124)
Error |
at grails.plugin.databasemigration.ScriptUtils.createAndPrintFixedDiff(ScriptUtils.groovy:245)
Error |
at grails.plugin.databasemigration.ScriptUtils$createAndPrintFixedDiff$1.call(Unknown Source)
Error |
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
Error |
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
Error |
at DbmGormDiff$_run_closure1_closure2_closure3.doCall(DbmGormDiff:53)
Error |
at DbmGormDiff$_run_closure1_closure2_closure3.doCall(DbmGormDiff)
Error |
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Error |
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
Error |
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
Error |
at java.lang.reflect.Method.invoke(Method.java:606)
Error |
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:207)
Finally, I figured out what the problem was. It wasn't related to JVM or to the specified PermGen size after all.
I had one domain class which looked similar to the following:
package test
import org.grails.databinding.BindingFormat
import grails.persistence.Entity
@Entity
class TestDomain{
static constraints = {
}
}
Within the domain class no properties have been defined. The problem's solution was to solely delete this very domain class, to restart GGTS and then to run the dbm-generate-gorm or dbm-gorm-diff for the project again (dependent on the current status of your project - in my case I started the database from scratch again and used dbm-generate-gorm, but I assume that it should also work in case of dbm-gorm-diff). Eventually, the command is executed without any error.
EDIT:
I have to admit that my explanation was wrong.
It turned out that also with an additional domain class containing properties the same error occured within GGTS. When I removed the file again it worked properly. At this point I counted 35 domain classes within my project in different packages. Adding a domain class in any of the packages leading to more than 35 domain classes resulted in the mentioned PermGen error.
However, it seems that this behaviour is somehow related to GGTS because when I finally tried to run the dbm-generate-gorm-changelog
command from the command line it was not only much faster than GGTS but also succeeded without error.
At this point I'm not able to explain why it works in the command line and doesn't within GGTS.
It was also not necessary to set the environment variable GRAILS_OPTS="-Xmx1G -Xms256m -XX:MaxPermSize=2048m" which I also tried but didn't have any influence on the performance of the command line execution.