hls.js icon indicating copy to clipboard operation
hls.js copied to clipboard

Large Memory Usage in Chrome

Open stabiliser opened this issue 3 years ago • 4 comments

What do you want to do with Hls.js?

Playing the video on the hls demo site with default settings at https://hls-js-e9b6f668-5edb-4682-a6af-034455d028b1.netlify.app/demo, I've noticed Chrome us using almost 800MB of memory to play this 10 minute video (gets to 450MB after 4 minutes).

Is this normal, and is there any way to reduce the memory footprint?

What have you tried so far?

I have tried setting:

maxBufferLength maxMaxBufferLength backBufferLength maxBufferSize

To different values, but it doesn't appear to help.

stabiliser avatar Sep 21 '22 09:09 stabiliser

i use hls.js v1.1.1 , memory usage is stable at 8 until 10 MB

https://i.postimg.cc/pTg6b6BD/Memory.png

dioramayuanito avatar Sep 21 '22 09:09 dioramayuanito

@dioramayuanito the JavaScript VM instance shows 8MB for me as well, but Chrome Task Manager and Windows Task Manager both report up to 800MB usage for the Chrome Tab that is playing the video.

stabiliser avatar Sep 21 '22 09:09 stabiliser

i dont know which numbers should we count for measuring Chrome memory usage. i use Linux Mint MATE 20.1

https://i.postimg.cc/tCG0nsH9/Memory2.png

dioramayuanito avatar Sep 21 '22 09:09 dioramayuanito

Not a Contribution

When profiling performance on the demo page be sure to disable all demo-tabs - especially performance hungry ones like the "Timeline". If your goal is to profile performance and memory usage of the player itself, it is best to do so on a blank page in isolation of any other page elements or browser extensions. The netlify builds are also hosted at a cost to the maintainers who appreciate that developers not use them for extensive testing of the player.

We can look at leaks in the JavaScript heap, but browser app and tab memory usage are not something we can address.

robwalch avatar Sep 21 '22 17:09 robwalch

I can reproduce the issue here in its simplest form: https://hls-demo.azurewebsites.net/

After 7 minutes of playback, Task Manager is reporting 630MB usage. No other tabs open.

Files attached for the small website demo.

hlsdemo.zip

stabiliser avatar Sep 21 '22 23:09 stabiliser

Task Manager is reporting 630MB usage

As I stated, we can look at JS Heap usage, but if the issue you have is with how much memory a tab uses for video playback, please report the issue to the Chrome team.

This does not appear to be any different for other JS video players or even HTMLMediaElement only (src=) playback.

I played through the entire video on the page without tab memory usage exceeding 400MB. JS heap we well under 40MB.

During playback, typically over 200s of media was in the buffer at any time which at the level bitrate (($('video')[0].buffered.end(0) - $('video')[0].buffered.start(0)) * hls.levels[hls.currentLevel].bitrate * 1.25e-7) requires more than 100MB.

Closing as this is not a bug with HLS.js.

robwalch avatar Sep 22 '22 00:09 robwalch