From 5fcd576fc715885bbcc3da17ca028cebad065a8f Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Thu, 2 Oct 2025 09:05:12 -0400 Subject: [PATCH] [Perf] reduce memory usage by freeing playlist videos when playlist view is closed --- CHANGELOG.md | 1 + playlet-lib/src/components/PlaylistView/PlaylistUtils.bs | 4 +++- .../src/components/Services/Invidious/InvidiousService.bs | 2 ++ playlet-web/src/lib/Api/InvidiousApi.ts | 1 + 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cc087e92..3e60e252 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Bug: credentialTransferTokens should only be used with TV clients +- [Perf] reduce memory usage by freeing playlist videos when playlist view is closed ## [0.42.0] - 2025-09-30 diff --git a/playlet-lib/src/components/PlaylistView/PlaylistUtils.bs b/playlet-lib/src/components/PlaylistView/PlaylistUtils.bs index 85b563a3..99151d44 100644 --- a/playlet-lib/src/components/PlaylistView/PlaylistUtils.bs +++ b/playlet-lib/src/components/PlaylistView/PlaylistUtils.bs @@ -6,6 +6,8 @@ namespace PlaylistUtils end if appController@.PushScreen(playlistView) playlistView@.BindNode() - playlistView.content = contentNode + ' Clone the playlist because the videos will be loaded as children. + ' This allows the videos to be freed once the view is closed. + playlistView.content = contentNode.clone(false) end function end namespace diff --git a/playlet-lib/src/components/Services/Invidious/InvidiousService.bs b/playlet-lib/src/components/Services/Invidious/InvidiousService.bs index 1dfe43ca..0c451d61 100644 --- a/playlet-lib/src/components/Services/Invidious/InvidiousService.bs +++ b/playlet-lib/src/components/Services/Invidious/InvidiousService.bs @@ -556,6 +556,8 @@ namespace Invidious end if json.type = "playlist" + ' Since we only want the playlist info, we can remove the videos array + json.Delete("videos") return { items: [json] } diff --git a/playlet-web/src/lib/Api/InvidiousApi.ts b/playlet-web/src/lib/Api/InvidiousApi.ts index 1e19ecc6..4cf8883f 100644 --- a/playlet-web/src/lib/Api/InvidiousApi.ts +++ b/playlet-web/src/lib/Api/InvidiousApi.ts @@ -241,6 +241,7 @@ export class InvidiousApi { private async PlaylistInfoHandler(feedSource, responseJson) { responseJson.type = "playlist"; + delete responseJson.videos; return { items: [responseJson] }; }