Skip to content

Commit

Permalink
fix(preload): Fix memory leak with preload feature (#6894)
Browse files Browse the repository at this point in the history
There was a memory leak where the segments that the PreloadManager
prefetched did not get cleaned up, after the player unloads. This fixes
that memory leak.

Fixes #6883
  • Loading branch information
theodab committed Jun 24, 2024
1 parent 752df76 commit 88d2a02
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/media/streaming_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ shaka.media.StreamingEngine = class {
for (const state of this.mediaStates_.values()) {
this.cancelUpdate_(state);
aborts.push(this.abortOperations_(state));
if (state.segmentPrefetch) {
state.segmentPrefetch.clearAll();
state.segmentPrefetch = null;
}
}
for (const prefetch of this.audioPrefetchMap_.values()) {
prefetch.clearAll();
Expand Down Expand Up @@ -244,6 +248,7 @@ shaka.media.StreamingEngine = class {
if (!(config.segmentPrefetchLimit > 0)) {
// ResetLimit is still needed in this case,
// to abort existing prefetch operations.
state.segmentPrefetch.clearAll();
state.segmentPrefetch = null;
}
} else if (config.segmentPrefetchLimit > 0) {
Expand Down

0 comments on commit 88d2a02

Please sign in to comment.