Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

JWPlayer memory leaking


Here's the simple page I'm testing:

<!DOCTYPE html>
<html>
<head>
<title>JWPlayer testing grounds</title>
<script type="text/javascript" src="../../libs/jquery.js"></script>
<script type="text/javascript" src="../../js/jw/jwplayer.js"></script>
</head>
<body>
<button onclick="init()">init</button>
<button onclick="cleanup()">cleanup</button>
<div id="content" class="">
<div id="video"></div>
</div>
</body>
<script type="text/javascript">
var cleanup = function() {
if ( window.jwplayer && window.jwplayer() && window.jwplayer().remove ) {
try {
jwplayer("video").remove();
} catch(e) {
console.log(e);
}
}
};

var init = function() {
jwplayer.key="insert key here";
jwplayer("video").setup({
sources: [{
file: "http://s3.amazonaws.com/tn8newdevcontent/19/b909a1383fcdc8aababdae501242cb731add809b/2291/shared/big_buck_bunny.mp4", type:"mp4"
},{
file: "http://s3.amazonaws.com/tn8newdevcontent/19/b909a1383fcdc8aababdae501242cb731add809b/2291/shared/big_buck_bunny.webm", type:"webm"
}],
width: "400px",

logo: {hide: true},
skin: "../../js/jw/six/six.css"
})
}

</script>
</html>

Now, if I analyze this with the chrome dev tools I can see an increase of nodes after following these steps: init, cleanup, garbage collect.

On cleanup I am calling the jwplayer().remove() function to cleanup the player but it's not clearing up everything as expected. Before initializing the player there are 32 nodes on the page and after cleanup and garbage collection we are still left with 201 nodes. So there's an extra 169 nodes being left after the player is deleted. Even if this is expected, repeating the process continually will keep adding 9 nodes at a time. This is on top of the 169 nodes that are left behind no matter what. To clarify these are the nodes shown in the dev tools when recording a memory timeline.

Is there some way we can prevent this memory leak in our cleanup of the player or is this something that needs to be changed inside the jwplayer itself?

2 Community Answers

Todd

JW Player Support Agent  
0 rated :

Thank you for providing this reproduction code. I will escalate this to our engineers and let you know what they come back with.

Todd

JW Player Support Agent  
0 rated :

Here’s the response I got from our product manager:

After calling remove there is still an instance of the player in memory, we do not delete from memory on remove. When you setup again we replace those nodes. We do not think this is cause for serious concern, we can look into it for a future release. Thanks for bringing it to our attention.

This question has received the maximum number of answers.