I have a webpage that runs an HTML5 SharedWorker script. Chrome memory usage increases every time this page reloads (pressing F5).
The working script is very simple. Every second (using setInterval ) a message is sent to the connected port.
It seems like the workflow is completing and restarting every time I press F5. This is what I expect, because in reality the employee is not shared by more than one “document”. However, I cannot understand why the memory usage is increasing with every update.
Does anyone know why this is happening?
Given that the memory increases every time the page reloads, it seems to me that I can’t use shared users in Chrome at all. Could anyone do this without memory problems?
UPDATE
This is HTML hosting:
<div id="output"></div> <script type="text/javascript" src="/scripts/jquery-1.4.4.js"></script> <script type="text/javascript"> $(function () { var worker = new SharedWorker("/scripts/worker.js") worker.port.onmessage = function(e) { $("#output").append($("<div></div>").text(e.data)); }; worker.port.start(); }); </script>
... and this is worker.js :
var list = []; setInterval(function () { for (var i = 0; i < list.length; ++i) { list[i].postMessage("#connections = " + list.length); } }, 1000); onconnect = function (event) { list.push(event.ports[0]); };
The hosting page starts / connects to the shared worker and displays everything that is received from it.
The working code stores a list of connected ports and sends a message to all of them once a second.
This is simple stuff. However, every time the hosting page reloads in Chrome. The memory payload for this tab has been increased.
The following shows the use of Chrome memory after several updates:

... after the upgrade, I still reach 250 MB ...

I'm running out of ideas thinking it's a bug in Chrome. Can someone give me some kind of pointer?
UPDATE 2
Disabling my AdBlock extension seems to fix the problem:

So, I was a little happy, but it turned out that the memory is still leaking . If AdBlock is disabled, it just runs a little less on page refresh.