grunt "minall" step fails with Error: Could not create virtual machine. (Solution found, unsure about PR) #4595
Description
All steps outlined for building the Angular project would work right up until I ran grunt package
. At that point it would run until it made it to the "minall"
task and it would fail.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Problem discovered
Upon further investigation I went into lib/utils.js
and had grunt.log print out the shell command it was executing to run closure.jar against each file.
The command that was being run was:
java -Xmx2g -cp bower_components/closure-compiler/compiler.jar;bower_components/ng-closure-runner/ngcompiler.jar org.angularjs.closurerunner.NgClosureRunner --compilation_level SIMPLE_OPTIMIZATIONS --language_in ECMASCRIPT5_STRICT --minerr_pass --minerr_errors build/angular-sanitize-errors.json --minerr_url http://errors.angularjs.org/undefined/ --source_map_format=V3 --create_source_map build/angular-sanitize.min.js.map --js build/angular-sanitize.js1--js_output_file build/angular-sanitize.min.js
At that point I was given the message(s):
Error occurred during initialization of VM
Could not reserve enough space for object heap
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Apparently my 32-bit JVM on Windows 7 does not like allocating 2gb of space. I'm not sure why, because AFAIK, 2gb is the maximum heap size value.
Workaround
When I changed -Xmx2g
to -Xmx512m
everything worked fine and I was able to build.
Question(s)
- Given the nature of how this JVM is being used, is 2GB max heap really necessary, or can it be reduced to 512MB?
- Should this be handled in the
java32flags()
function inutils
? In other words, if it's a 32 bit JVM should the max heap flag be reduced, whereas 64-bit JVM could state the same?
... either way I'm glad I finally got past this issue at least locally.