title: Memory Leak in Express.js with EventSource
body: <p>I think I am running into a memory leak with an <strong>Express</strong> app when connecting x number of <strong>EventSource</strong> clients to it. After connecting the clients and sending them x messages and disconnecting them, my <strong>Express</strong> app only releases a small amount of the allocated Heap/RSS. </p>
  
  <p>To confirm this I saved a <strong>Heapdump</strong> when starting the server and one after connecting 7,000 clients to it and sending x messages to each client. I waited for a while to give the GC a chance to clean up before taking the heap snapshot.</p>
  
  <p>To compare these heap snapshots I loaded them in the Chrome Developer Tools Profile view and chose the "Comparison" mode.</p>
  
  <p>My questions are: </p>
  
  <p><strong>1)</strong> How to interpret these numbers?
  <em>(For reference see the attached heap snapshot screenshot.)</em></p>
  
  <p><strong>2)</strong> For instance it looks like that the <strong>Socket</strong> objects doesn't almost free any objects at all, is that correct?</p>
  
  <p><strong>3)</strong> Can you give me more tips to investigate the problem?</p>
  
  <p><img src="https://i.stack.imgur.com/90cHq.png" alt="Heap Snapshot Express.js app"></p>