Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Web Worker Memory Leak?

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>
like image 499
Jon Senchyna Avatar asked Oct 21 '22 13:10

Jon Senchyna


1 Answers

This is a memory leak in Chrome v25. It appears to be fixed in Chrome v26, as the issue can no longer be reproduced.

like image 184
Jon Senchyna Avatar answered Oct 28 '22 21:10

Jon Senchyna