I've been using Chrome's Timeline view to attempt to track down some memory leaks in my page. I've found one particular memory leak that results from instantiating web workers that I can't seem to figure out how to get rid of.
I've stripped down the page to just load the web worker and do nothing else. Every time I refresh the page, the Document Count on Chrome's timeline view permanently increases by 1. If I comment out the call to the Worker constructor, and begin refreshing the page, the document count increases and then decreases, effectively staying the same. Manually terminating/closing the worker does not resolve the issue (although I can see the worker disappear when I look at the Sources tab of the developer tools).
Here is my trimmed down .htm file. I am able to reproduce the issue with just this short chunk of html/javascript:
<html>
<script type="text/javascript">
var worker_blob = new Blob(["var test = 1;"]);
var worker_url = window.URL.createObjectURL(worker_blob);
// Comment out the line below and the memory leak goes away
var worker = new Worker(worker_url);
window.URL.revokeObjectURL(worker_url);
</script>
</html>
This is a memory leak in Chrome v25. It appears to be fixed in Chrome v26, as the issue can no longer be reproduced.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With