<p dir="auto">Since Deno 1.31 upgrade, on startup and at each tab completion an error message is logged.<br>
Platform: windows 11</p>
<p dir="auto">Full re-install, cleaning cache, ... not solving this issue<br>
Downgrading solve it<br>
Install on VM don't seems to have this issue</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="Could not set npm package requirements. Error getting response at https://registry.npmjs.org/npm for package &quot;npm&quot;: An npm specifier not found in cache: &quot;npm&quot;, --cached-only is specified.
Deno 1.31.1
exit using ctrl+d, ctrl+c, or close()
REPL is running with all permissions allowed.
To specify permissions, run `deno repl` with allow flags.
&gt; MCould not set npm package requirements. Error getting response at https://registry.npmjs.org/npm for package &quot;npm&quot;: An npm specifier not found in cache: &quot;npm&quot;, --cached-only is specified.

Map             Math            MessageChannel  MessageEvent    MessagePort"><pre class="notranslate">Could not <span class="pl-c1">set</span> npm package requirements. Error getting response at https://registry.npmjs.org/npm <span class="pl-k">for</span> <span class="pl-smi">package <span class="pl-s"><span class="pl-pds">"</span>npm<span class="pl-pds">"</span></span>: An npm specifier not found</span> <span class="pl-k">in</span> cache: <span class="pl-s"><span class="pl-pds">"</span>npm<span class="pl-pds">"</span></span>, --cached-only is specified.
Deno 1.31.1
<span class="pl-c1">exit</span> using ctrl+d, ctrl+c, or <span class="pl-en">close</span>()
REPL is running with all permissions allowed.
To specify permissions, run <span class="pl-s"><span class="pl-pds">`</span>deno repl<span class="pl-pds">`</span></span> with allow flags.
<span class="pl-k">&gt;</span> MCould not <span class="pl-c1">set</span> npm package requirements. Error getting response at https://registry.npmjs.org/npm <span class="pl-k">for</span> <span class="pl-smi">package <span class="pl-s"><span class="pl-pds">"</span>npm<span class="pl-pds">"</span></span>: An npm specifier not found</span> <span class="pl-k">in</span> cache: <span class="pl-s"><span class="pl-pds">"</span>npm<span class="pl-pds">"</span></span>, --cached-only is specified.

Map             Math            MessageChannel  MessageEvent    MessagePort</pre></div>
<p dir="auto">Hello. So, I was testing Deno 1.9.2 with a workload that involves <a href="https://github.com/tc39/proposal-temporal">Temporal</a> and a Postgres database. I noticed that after a few minutes, the 2GB VPS just ran out of memory after some batches of processing. I did the following:</p>
<ol dir="auto">
<li>Tried to profile using <code class="notranslate">--inspect</code>, but I noticed that it never went above 20MB, so it was probably not a "normal" JavaScript leak. I think Deno lacks GC information in the DevTools profiler, so that wasn't helpful.</li>
<li>I proceeded to compile Deno in debug mode, upload to VPS, run with the workload using <code class="notranslate">LD_PRELOAD=/usr/lib/libtcmalloc.so</code> and a <code class="notranslate">HEAPPROFILE</code>.</li>
<li>The results were in. And looks like it's Intl.DateTimeFormat that is at fault.<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/3057302/117035008-3e1f0380-acda-11eb-88f4-d32d252664d9.png"><img src="https://user-images.githubusercontent.com/3057302/117035008-3e1f0380-acda-11eb-88f4-d32d252664d9.png" alt="leak_result" style="max-width: 100%;"></a></li>
<li>Then I looked for similar issues. Found: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="569367635" data-permission-text="Title is private" data-url="https://github.com/nodejs/node/issues/31914" data-hovercard-type="issue" data-hovercard-url="/nodejs/node/issues/31914/hovercard" href="https://github.com/nodejs/node/issues/31914">nodejs/node#31914</a>, seems related, and listed as fixed for v8, but let's try the repro. Created a file leak.ts, ran with deno and watched the resident memory climb up to 5.4G. Ran with node, it also looks "leaky", but it only goes up to 1.3G.</li>
</ol>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="setInterval(() =&gt; {
  var a;
  for (let i = 0; i &lt; 100; i++) {
    a = new Intl.DateTimeFormat(&quot;en&quot;).format(Date.now());
  }
}, 1);"><pre class="notranslate"><span class="pl-en">setInterval</span><span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
  <span class="pl-k">var</span> <span class="pl-s1">a</span><span class="pl-kos">;</span>
  <span class="pl-k">for</span> <span class="pl-kos">(</span><span class="pl-k">let</span> <span class="pl-s1">i</span> <span class="pl-c1">=</span> <span class="pl-c1">0</span><span class="pl-kos">;</span> <span class="pl-s1">i</span> <span class="pl-c1">&lt;</span> <span class="pl-c1">100</span><span class="pl-kos">;</span> <span class="pl-s1">i</span><span class="pl-c1">++</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-s1">a</span> <span class="pl-c1">=</span> <span class="pl-k">new</span> <span class="pl-v">Intl</span><span class="pl-kos">.</span><span class="pl-c1">DateTimeFormat</span><span class="pl-kos">(</span><span class="pl-s">"en"</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">format</span><span class="pl-kos">(</span><span class="pl-v">Date</span><span class="pl-kos">.</span><span class="pl-en">now</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-kos">}</span>
<span class="pl-kos">}</span><span class="pl-kos">,</span> <span class="pl-c1">1</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<ol start="5" dir="auto">
<li>The same code with a similar object, <code class="notranslate">Intl.NumberFormat</code>, peaks at 100M for node, and 258M for deno. I assume that is normal.</li>
</ol>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="setInterval(() =&gt; {
  var a;
  for (let i = 0; i &lt; 100; i++) {
    a = new Intl.NumberFormat(&quot;en&quot;).format(3);
  }
}, 1);"><pre class="notranslate"><span class="pl-en">setInterval</span><span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
  <span class="pl-k">var</span> <span class="pl-s1">a</span><span class="pl-kos">;</span>
  <span class="pl-k">for</span> <span class="pl-kos">(</span><span class="pl-k">let</span> <span class="pl-s1">i</span> <span class="pl-c1">=</span> <span class="pl-c1">0</span><span class="pl-kos">;</span> <span class="pl-s1">i</span> <span class="pl-c1">&lt;</span> <span class="pl-c1">100</span><span class="pl-kos">;</span> <span class="pl-s1">i</span><span class="pl-c1">++</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-s1">a</span> <span class="pl-c1">=</span> <span class="pl-k">new</span> <span class="pl-v">Intl</span><span class="pl-kos">.</span><span class="pl-c1">NumberFormat</span><span class="pl-kos">(</span><span class="pl-s">"en"</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">format</span><span class="pl-kos">(</span><span class="pl-c1">3</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-kos">}</span>
<span class="pl-kos">}</span><span class="pl-kos">,</span> <span class="pl-c1">1</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<ol start="6" dir="auto">
<li>I couldn't change this memory ceiling by using <code class="notranslate">--v8-flags=--max-old-space-size</code>, so I guess it's completely external to that.</li>
</ol>
<hr>
<p dir="auto">I think it's probably an issue in V8 itself that has not been correctly resolved, and deno and node both handle it differently. I will try to change Temporal to reuse the same <code class="notranslate">Intl.DateTimeFormat</code> instance, for now, but it would be nice if this could be fixed.</p>