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

Memory leak when using reactive/ref in SSR mode #5649

Closed
yeyan1996 opened this issue Mar 30, 2022 · 1 comment
Closed

Memory leak when using reactive/ref in SSR mode #5649

yeyan1996 opened this issue Mar 30, 2022 · 1 comment

Comments

@yeyan1996
Copy link
Contributor

yeyan1996 commented Mar 30, 2022

Version

3.2.31

Reproduction link

github.com/yeyan1996/vite-ssr

Steps to reproduce

  1. download repository
  2. using npm run serve to start the server
  3. see reactiveMap in the dist/server/entry-server folder

image

image

What is expected?

reactiveMap should be empty in server SSR

What is actually happening?

reactiveMap is expanding


This issue is similar to #5208

I didn't find any other variable to tell if it's currently server-rendered(maybe window === undefined?)

So is it possible to build a branch for SSR? (I see there is a __SSR__ variable in the source code)

Or other solutions, thx

@yyx990803 yyx990803 added scope: ssr ❗ p4-important Priority 4: this fixes bugs that violate documented behavior, or significantly improves perf. and removed ❗ p4-important Priority 4: this fixes bugs that violate documented behavior, or significantly improves perf. labels Apr 13, 2022
@yyx990803
Copy link
Member

We'll need a bit more info to confirm that this is indeed a memory leak - reactiveMap is a WeakMap - which means an entry can be released if its key is no longer referenced anywhere.

Your console.log() may cause the console to iterate the WeakMap and thus prevent all keys to be released.

To show a memory leak, please provide a repro similar to that of #5208.

@github-actions github-actions bot locked and limited conversation to collaborators Sep 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants