user619271 user619271 - 6 months ago 910
Node.js Question

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory

Node version is

v0.11.13


Memory usage during crash according to
sudo top
not raises over
3%


Code that reproduces this error:

var request = require('request')
var nodedump = require('nodedump')

request.get("http://pubapi.cryptsy.com/api.php?method=marketdatav2",function(err,res)
{
var data
console.log( "Data received." );
data = JSON.parse(res.body)
console.log( "Data parsed." );
data = nodedump.dump(data)
console.log( "Data dumped." );
console.log( data )
})


To check if that a recursion stack size problem I have ran next code with --stack-size=60000 parameter

var depth = 0;

(function recurse() {
// log at every 500 calls
(++depth % 500) || console.log(depth);
recurse();
})();


and have got

264500
Segmentation fault


Then I ran code which gives me FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory with the same --stack-size=60000 parameter and haven't got
Segmentation fault
.

So I conclude
CALL_AND_RETRY_LAST
has nothing common with the recursion stack size.

How could I solve this problem? I believe there is enough free memory on my computer to finish this task successfully.

There are similar questions on stackoverflow but none of this questions are about
CALL_AND_RETRY_LAST
that's why I created separate question.

Answer

If you have a look at the source: github/v8, it seams that you try to reserve one very big object? My experience is this happens if you try to parse a huge JSON object, but when I try to parse your output with JSON and node0.11.13, it just works fine.

You don't need more --stack-size, you need more memory: --max_new_space_size and/or --max_old_space_size.

The only hint I can give you beside that: try another JSON-parser and/or try to change the input format to JSON line instead of JSON only.

Comments