FATAL ERROR: JS Allocation failed - process out of memory

1,037 views
Skip to first unread message

Mark Boyd

unread,
Jul 19, 2012, 11:08:45 AM7/19/12
to ugli...@googlegroups.com
I installed uglify-js on my development box (windoze 7) with: "c:\Program Files\nodejs\npm.cmd" install uglify-js which ran fine. And I can run the command line tool to minify a file just fine using cygwin. But when I follow the programmatic steps to minify code within my node app I get:

FATAL ERROR: JS Allocation failed - process out of memory

To elliminate the original code being minimized as the culprit I've dropped back to a very simple test function. Here is what I have currently in my express application:

var parser = require("uglify-js").parser,
     procsr = require("uglify-js").uglify;

var testcode = (function() {
return "hello world";
}); 

console.log("---> parse");
var ast = parser.parse(testcode); 
console.log("---> ast_mangle");
ast = procsr.ast_mangle(ast); 
console.log("---> ast_squeeze");
ast = procsr.ast_squeeze(ast); 
console.log("---> gen_code");
var final_code = procsr.gen_code(ast); 
console.log("---> compressed = " + final_code.toString());

The only lines of output from the node process that I see are as follows with parse taking perhaps 30 seconds before the 'out of memory' line appears. I am using cluster and express. Any suggestions on what could be going wrong?

node server.js
Server running on port 8999
worker 2 online
worker 1 online
---> parse
FATAL ERROR: JS Allocation failed - process out of memory
worker 1 died (1). restarting...
worker 3 online

Mark

Mark Boyd

unread,
Jul 19, 2012, 11:16:23 AM7/19/12
to ugli...@googlegroups.com
For the record here is the npm output. So I am on uglify-js 1.3.2. 

"c:\Program Files\nodejs\npm.cmd" install uglify-js

Mark Boyd

unread,
Jul 19, 2012, 12:00:43 PM7/19/12
to ugli...@googlegroups.com
To elliminate dependency problems I created a standalone file uglifytest.js with these lines and ran this on its own with 'node uglifytest.js' with identical results. The problem still occurred. So I'm guessing that it must be something with my environment.

var parser = require("uglify-js").parser,
procsr = require("uglify-js").uglify;


var testevaluate = (function() {
return "hellow world";
}); 

console.log("---> parse");
var ast = parser.parse(testevaluate); // parse code and get the initial AST
console.log("---> ast_mangle");
ast = procsr.ast_mangle(ast); // get a new AST with mangled names
console.log("---> ast_squeeze");
ast = procsr.ast_squeeze(ast); // get an AST with compression optimizations
console.log("---> gen_code");
var final_code = procsr.gen_code(ast); // compressed code here
console.log("---> compressed = " + final_code.toString());

Output from the process was as follows with a significant delay between the parse line output and the fatal error:

node uglifytest.js
---> parse
FATAL ERROR: JS Allocation failed - process out of memory

Mark

Mark Boyd

unread,
Jul 19, 2012, 12:09:11 PM7/19/12
to ugli...@googlegroups.com
And it doesn't matter if I start node in a cygwin bash shell or a windoze console. Same results.

Mark
Reply all
Reply to author
Forward
0 new messages