问题
I am working on GGTS 3.5 and Grails version 2.3.7. When i run my project, we are facing an issue with Heap size.
Windows 7 32 bit; RAM: 3gb.
Java 1.7 .
I set below environment variables as well.
GRAILS_OPTS = -XX:MaxPermSize=1024m -Xmx1024m -server
JAVA_OPTS = -XX:MaxPermSize=1024m -Xmx1024m -server
and changed my GRAILS_OPTS
in start grails file. But still facing the same issue.
I have just started working in java and grails, please help me out. Many thanks in advance. Error Desc:
Loading Grails 2.3.7
Configuring classpath .
Environment set to development .................................
Packaging Grails application ..........................................
Running Grails
application Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Error occurred during initialization of VM
Could not reserve enough space for object heap
Error | Forked Grails VM exited with error
回答1:
You may have to change memory parameters in your BuildConfig
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: 256, daemon:true],
// configure settings for the run-app JVM
run: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false],
// configure settings for the run-war JVM
war: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false],
// configure settings for the Console UI JVM
console: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256]
]
回答2:
Below approach fixed the issue for me
Inside GRAILS_HOME\bin there's a batch file named startGrails.bat
Edit the file and change the Xmx and Xms size mentioned:
set GRAILS_OPTS=-server -Xmx1024M -Xms512M -Dfile.encoding=UTF-8
restart the grails.
回答3:
Also to much (little) dynamic groovy code in grails app (inside of domain sub method) can decrease free heap size. After corrected dynamic/indirect code into local variable on each statement, a heap problem vanished.
来源:https://stackoverflow.com/questions/23560245/could-not-reserve-enough-space-for-object-heap-in-grails