Getting an out of memory of error when no memory storage is used except two variables(i & j). Can someone please clarify.
I'm not storing anywhere in memory or writing it to any storage, whatever is generated gets spits to console and need to move to next instruction.
console.log('num,num2,op,result');
for(i=9.0;i>=0;) {
for(j=9.0;j>=0;) {
console.log(i.toFixed(3) + ',' + j.toFixed(3) + ',+,' + (i+j).toFixed(3));
j =parseFloat((j - 0.001).toFixed(3));
}
i =parseFloat((i - 0.001).toFixed(3));
}
Executing this getting stack error,
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
1: node::Abort() [/usr/local/bin/node]
2: node::FatalException(v8::Isolate*, v8::Local<v8::Value>, v8::Local<v8::Message>) [/usr/local/bin/node]
3: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [/usr/local/bin/node]
4: v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [/usr/local/bin/node]
5: v8::internal::Runtime_AllocateInTargetSpace(int, v8::internal::Object**, v8::internal::Isolate*) [/usr/local/bin/node]
6: 0x3006473079a7
Abort trap: 6
Please let me know what I'm missing to avoid memory crash.
More Research:
To our code, it does not make any difference whether console.log is async or not, it does not provide any kind of callback or so; and the values you pass are always referenced and computed at the time you call the function.
Reference: console.log() async or sync?
It references the data only at the time of referring the data associated with it.
Will also check for any memory leaks associated with parseFloat or toFixed.