Merge pull request #102 from UniversityRadioYork/markspolakovs-bloody-memory-leak
Squish a memory leak
This commit is contained in:
commit
a0fd02f897
1 changed files with 7 additions and 0 deletions
|
@ -19,6 +19,7 @@ const playerGainTweens: Array<{
|
||||||
tweens: Between[];
|
tweens: Between[];
|
||||||
}> = [];
|
}> = [];
|
||||||
const loadAbortControllers: AbortController[] = [];
|
const loadAbortControllers: AbortController[] = [];
|
||||||
|
const lastObjectURLs: string[] = [];
|
||||||
|
|
||||||
type PlayerStateEnum = "playing" | "paused" | "stopped";
|
type PlayerStateEnum = "playing" | "paused" | "stopped";
|
||||||
type PlayerRepeatEnum = "none" | "one" | "all";
|
type PlayerRepeatEnum = "none" | "one" | "all";
|
||||||
|
@ -297,6 +298,12 @@ export const load = (
|
||||||
|
|
||||||
const playerInstance = await audioEngine.createPlayer(player, objectUrl);
|
const playerInstance = await audioEngine.createPlayer(player, objectUrl);
|
||||||
|
|
||||||
|
// Clear the last one out from memory
|
||||||
|
if (typeof lastObjectURLs[player] === "string") {
|
||||||
|
URL.revokeObjectURL(lastObjectURLs[player]);
|
||||||
|
}
|
||||||
|
lastObjectURLs[player] = objectUrl;
|
||||||
|
|
||||||
playerInstance.on("loadComplete", (duration) => {
|
playerInstance.on("loadComplete", (duration) => {
|
||||||
console.log("loadComplete");
|
console.log("loadComplete");
|
||||||
dispatch(mixerState.actions.itemLoadComplete({ player }));
|
dispatch(mixerState.actions.itemLoadComplete({ player }));
|
||||||
|
|
Loading…
Reference in a new issue