I am utilizing Video Text Tracks to showcase advanced live information on top of the video.
A new video is loaded every few minutes, each with its own .webvtt file (consisting of 2-3k lines).
Although everything is functioning properly, there is a persistent issue with memory usage increasing continuously.
This problem stems from a memory leak where additional VTTCue and TextTrack records are added for each new video, leading to an accumulation of unnecessary data. https://i.stack.imgur.com/HN3Ln.png
After trying several approaches without success, I find myself stuck with the current method:
The text tracks are implemented according to the guidelines in the Video.js documentation (remote text tracks):
player.ready(() => {
if (videoOptions.subtitles) {
player.addRemoteTextTrack(
{
src: videoOptions.subtitles,
kind: 'subtitles',
},
false,
);
}
});
And they are removed before disposing of the player:
const remoteTextTracks = this.player.remoteTextTracks();
for (let i = remoteTextTracks.length - 1; i >= 0; i -= 1) {
this.player.removeRemoteTextTrack(remoteTextTracks[i]);
}
Even though they are successfully removed from the player, they linger in memory. Is there a way to prompt/urge/force the GC to completely eliminate old text tracks?