Skip to content

Release a folder's children once its subtree has been scanned - #17884

Merged
crobibero merged 2 commits into
jellyfin:release-12.zfrom
Shadowghost:fix/17860-scan-children-retention
Sep 14, 2026
Merged

crobibero merged 2 commits into
jellyfin:release-12.zfrom
Shadowghost:fix/17860-scan-children-retention

Conversation

@Shadowghost

Copy link
Copy Markdown
Contributor

Folder.Children is a cache on the instance, and a folder instance stays reachable from the root folder the library manager holds for the lifetime of the process. Every existing Children = null invalidates before a read but nothing dropped the cache once a folder was done with.
This is an issue because a recursive scan touches every level, so the validate phase ended up holding the
whole item graph of the library at once.

A retained item also pinned its EF entity graph: BaseItemMapper handed the domain item the entity's own user data collection, whose rows point back at the BaseItemEntity through UserData.Item and at the User through UserData.User. Nothing reads those navigations off a domain item.

Measured on the same library and scan: live heap 107 MB at 25%, 87 MB at 46% and 156 MB at 71% flat with BaseItemEntity down from 11,083 to 1 and peak RSS from 5.78 GB to 4.32 GB.

Changes

  • ReleaseCachedChildren drops what a folder has materialised, and what the folders below it hold, without loading anything that is not already in memory.
  • Copy the rows detached for the domain items.

Code assistance
Claude Opus 5 was used to benchmark different solutions on my prod dataset.

Issues
Fixes #17860

@Shadowghost Shadowghost added the stable backport Backport into the next stable release label Sep 8, 2026
@jellyfin-bot

Copy link
Copy Markdown
Contributor

Jellyfin API (v 12.0.0)


Result


No differences. Specifications are equivalent

@gummykage

Copy link
Copy Markdown

@Shadowghost Would this be merged to the next unstable build for testing? (Sorry not fully understanding the github work flows) Looking forward!

@Shadowghost

Copy link
Copy Markdown
Contributor Author

No, this would go into the next patch release of 12.x. If you want to test beforehand, you'd need to build from source

@Shadowghost
Shadowghost marked this pull request as ready for review September 9, 2026 06:01
@theguymadmax theguymadmax moved this from Todo to Review in Jellyfin v12 Sep 9, 2026
@theguymadmax
theguymadmax requested a review from a team September 10, 2026 16:28
@Adamstuhltrager

This comment was marked as low quality.

@crobibero

Copy link
Copy Markdown
Member

Should also make this change to MusicAlbum

@sonarqubecloud

Copy link
Copy Markdown

@Shadowghost
Shadowghost requested a review from a team September 12, 2026 05:57
@jellyfin-project-automation jellyfin-project-automation Bot added this to the v12.1 milestone Sep 12, 2026
@crobibero
crobibero merged commit 2f2adae into jellyfin:release-12.z Sep 14, 2026
16 of 18 checks passed
@github-project-automation github-project-automation Bot moved this from Review to Done in Jellyfin v12 Sep 14, 2026
joshuaboniface pushed a commit that referenced this pull request Sep 15, 2026
Release a folder's children once its subtree has been scanned

Original-merge: 2f2adae

Merged-by: crobibero <cody@robibe.ro>

Backported-by: Cody Robibero <cody@robibe.ro>
@crobibero crobibero removed the stable backport Backport into the next stable release label Sep 15, 2026
dux-nine added a commit to Start9Labs/advisories that referenced this pull request Sep 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants