title: Manage memory in NodeJs
body: <p>I made a script with Node.js. When I execute it in the console, it opens and reads a big file and loops over lines in that file.</p>
  
  <p>The problem is that for reading the file, the script allocates 200MB of memory, but for looping over each line, over 1.5 GB is used</p>
  
  <p>In the code, I don't accumulate data in arrays or strings. All the code is in a loop and any variable is overwriting in the next loop. </p>
  
  <p>How can I reduce memory usage? If the problem is in any variable, where I accumulate data, how to detect that? </p>
  
  <p>I didn't share the code, because it's a big script. I only need ways for liberate memory, or detect the memory leak.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I don't Undrtant why the user delete his aswer... 
  This solution work for me. Is a problem with garbage. If I force the GC, that's work!</p>
  
  <blockquote>
    <p>node --expose-gc test.js</p>
  </blockquote>
  
  <p>And then from within the Javascript just do:</p>
  
  <blockquote>
    <p>global.gc();</p>
  </blockquote>