Search code examples
javascriptnode.jsspecificationsecma

Maximum object children on node js


I'm aware that the ECMA script spec says that an object can have infinite children however I also understand many ECMA script implementations do not conform to this. I was wondering if node has a limit on the amount of children an object can have?

Thanks, Ed.


Solution

  • Yes it can but until heap out of memory.

    var a = {};
    var i = 0;
    while(true){
        a[i] = null;
        i++;
    }
    

    FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

    So it depends on your memory size.