Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not use global cache for createCache() to avoid memory leaks #3110

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Commits on Sep 21, 2023

  1. Return cache directly in getServerStylisCache

    We are never using the accessor function that is returned.
    In the code base later we access it like this:
    `serverStylisCache[name]` and not like this `serverStylisCache(name)`
    
    While we could change the access,
    I'm not sure how we would write to the cache.
    So I think we can just directly return the cache object.
    functino committed Sep 21, 2023
    Configuration menu
    Copy the full SHA
    72834f3 View commit details
    Browse the repository at this point in the history
  2. Move creation of stylisCache inside createCache function

    Currently we share caches even for multiple createCache() calls.
    
    So if you have an SSR app that reates a cache on the server like this:
    
    const cache = createCache({ key: 'custom' });
    
    and you do this (like recommended) on every request, you still share a cache
    between all requests. I also think this is currently a memory leak.
    If you have a big application and maybe even lots of dynamic styles
    the cache can get quite big and will never be garbage collected.
    functino committed Sep 21, 2023
    Configuration menu
    Copy the full SHA
    eaec045 View commit details
    Browse the repository at this point in the history
  3. Add changeset

    functino committed Sep 21, 2023
    Configuration menu
    Copy the full SHA
    c417aac View commit details
    Browse the repository at this point in the history