title: How to delete files in tmpfs or /tmp directory for Google Cloud Functions?
body: <p>I have a google cloud function I've written in Node.js which I have set to execute every 4 hours using the cloud scheduler. Basically the function populates a table I have in BigQuery. My function doesn't explicitly write anything to the tmp directory, it just stores things in local variables for streaming insertion into BigQuery like so:</p>
  
  <pre><code>var rows = []
  
  // code which fills the rows array
  
  await bigqueryClient
        .dataset(datasetId)
        .table(tableId)
        .insert(rows)
  </code></pre>
  
  <p>I've noticed (looking at the graph of memory usage) that the memory used with each invocation goes up until it reaches the limit set for the function (I have 512MB for this one), and then I get an error logged - "Error: memory limit exceeded. Function invocation was interrupted."</p>
  
  <p>I've tried the below code to try to remove all files in the tmp directory, but it seems like there are no files to delete:</p>
  
  <pre><code>const directory = '/tmp';
  
  fs.readdir(directory, (err, files) =&gt; {
    if (err) throw err
    console.log(files)
  
    for (const file of files) {
      fs.unlink(path.join(directory, file), err =&gt; {
        if (err) throw err
      })
    }
  })
  </code></pre>
  
  <p>What gets logged is just an empty array '[ ]'. </p>
  
  <p>What am I missing here? Is the problem something else?</p>