0

I am using function within function in javascript. I am reading files and pass to another function.

For example

 function function1()
 {
    var file1="sample text";              ///for example it takes 2 bytes memory
    function2();                          ///calling another function
    c=a+b;
 }

 function function2()
 {
    var file2="another sample text";    //Here another 2 bytes
    //do something
 }

I need to know how much memory it takes at the time of 'c=a+b' line execution.

Because I have Fatal error while handling large files.

The error :

 Fatal Error: CALL_AND_RETRY_LAST ALLOCATION failed. process out of memory.

Note: I have increase memory size by -- max_old_space_size=2000000. But after increase the function. The error again occur.

I am using the above logic(function within function).

I have doubt at variable memory.

Any one assist me.

Thanks in Advance.

Vanarajan
  • 973
  • 1
  • 10
  • 35
  • 1
    There is a hard limit on memory in NodeJS, even with the raised `max_old_space_size`, if your application reaches that limit, consider splitting into multiple workers or processes. – Madara's Ghost Nov 24 '15 at 08:15
  • 1
    Depends a lot what `//do something` is doing… specifically, whether it creates a closure over the string. If not, all values that were created in `function2` will be eligible for garbage collection as soon as the call returns. – Bergi Nov 24 '15 at 08:15

0 Answers0