title: NodeJS https request needs excessive memory
body: <p>I am trying to load the json of this url <a href="https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/AmazonEC2/current/index.json" rel="nofollow noreferrer">https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/AmazonEC2/current/index.json</a> . The file has over 600MB to download.</p>
  
  <p>I am using this code in a lambda function:</p>
  
  <p>The lambda function is setup with a timeout of 10min and 3008MB of memory. But the function is trying to use more than that.</p>
  
  <pre><code>let res = await doRequest2('https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/AmazonEC2/current/index.json');
  
  function doRequest2(url) {
    console.log("doRequest");
   return new Promise(function (resolve, reject) {
   const https = require("https");
   const url = "https://pricing.us-east-   1.amazonaws.com/offers/v1.0/aws/AmazonEC2/current/index.json";
   https.get(url, res =&gt; {
   res.setEncoding("utf8");
   let body = "";
   res.on("data", data =&gt; {
    body += data;
    });
    res.on("end", () =&gt; {
     body = JSON.parse(body);
   resolve(body);
   console.log(body);
     });
      res.on("error", () =&gt; {
   console.log("Error");
   reject("error");
       });
   });
  
  });
  }
  </code></pre>
  
  <p>How can the json download need so much memory?</p>