• Login
  • Register
  • Login Register
    Login
    Username/Email:
    Password:
    Or login with a social network below
  • Forum
  • Website
  • GitHub
  • Status
  • Translation
  • Features
  • Team
  • Rules
  • Help
  • Feeds
User Links
  • Login
  • Register
  • Login Register
    Login
    Username/Email:
    Password:
    Or login with a social network below

    Useful Links Forum Website GitHub Status Translation Features Team Rules Help Feeds
    Jellyfin Forum Development Server Development LibraryManager.cs Memory Cache

     
    • 0 Vote(s) - 0 Average

    LibraryManager.cs Memory Cache

    Excessive memory Usage due to lack of pruning
    TrueCodePoet
    Offline

    Junior Member

    Posts: 6
    Threads: 1
    Joined: 2025 Feb
    Reputation: 0
    #1
    2025-02-16, 05:06 AM
    I have been struggling with an issue for over a year now.  
    Despite having a server with 32GB of RAM, my server runs out of memory daily, Specifically the Jellyfin service consumes all available ram.  and I've noticed that I'm forced to restart the server service every day just to keep it running. 

    After some digging into the source, I suspect the root of the problem lies in how the LibraryManager handles caching.
    From what I gathered in the LibraryManager.cs source code, the application uses a ConcurrentDictionary to store every media item that's registered via the RegisterItem method. 

    Once an item is added to this cache, it stays there for the lifetime of the server process because there's no expiration or eviction policy in place. 
    Over time, especially as the media library grows (mine is well in the 10,000 range), this cache keeps accumulating items, which eventually leads to memory exhaustion.

    I’ve also noticed that this issue becomes even more pronounced when using tools that scan the library for missing content or applications like jellyseerr (I actually run a separate server just for this now).

    It seems that these operations increase the rate at which new items are cached, thereby accelerating the memory leak.
    I believe that adding a better way to manage this cache—perhaps by introducing an eviction strategy such as a Time-To-Live (TTL) or Least Recently Used (LRU) policy—could make a big difference. 

    It might also help to allow users to select the level of caching based on their environment and needs, which would go a long way toward scaling the application.

    I have read a few posts in the help section where some think ever expanding cache is a good thing.  I am not in this camp.  Cache only makes sense when it is very targeted and should allow the application to respect the server and other potential applications.

    Thanks for taking the time to read this. I hope this information is useful.
    « Next Oldest | Next Newest »

    Users browsing this thread: 1 Guest(s)


    Messages In This Thread
    LibraryManager.cs Memory Cache - by TrueCodePoet - 2025-02-16, 05:06 AM
    RE: LibraryManager.cs Memory Cache - by TheDreadPirate - 2025-02-16, 06:34 PM
    RE: LibraryManager.cs Memory Cache - by TrueCodePoet - 2025-02-16, 10:12 PM
    RE: LibraryManager.cs Memory Cache - by TrueCodePoet - 2025-02-17, 03:03 PM
    RE: LibraryManager.cs Memory Cache - by TrueCodePoet - 2025-02-20, 03:24 PM
    RE: LibraryManager.cs Memory Cache - by TrueCodePoet - 2025-02-20, 03:33 PM
    RE: LibraryManager.cs Memory Cache - by TrueCodePoet - 2025-02-21, 12:58 PM

    • View a Printable Version
    • Subscribe to this thread
    Forum Jump:

    Home · Team · Help · Contact
    © Designed by D&D - Powered by MyBB
    L


    Jellyfin

    The Free Software Media System

    Linear Mode
    Threaded Mode