-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 - Nuxt3 #2762
Comments
Given that the method is from Nuxt, please open a discussion or issue in Nuxt. |
I wonder if the same can be observed when not setting pinia state. Also, (Though @posva I think there might be some room for improvements to have sth. similar to |
Does the leak disappear with |
hey i also tried it with callOnce the leak is also there! I also tried it with https://vueuse.org/shared/createGlobalState/ and it also didn't change. I also tried useFetch when fetching and $fetch |
If the memory leak can only be reproduced with pinia then it is probably something to be tracked here. It could be an issue with the Nuxt module implementation. I’ll take a look, but if you could try to reproduce without pinia that would be helpful too. |
https://github.com/dissy123/nuxt-pinia-memory-leak/tree/without-pinia yes it also happens without pinia! when just using useAsyncData haven't tried callOnce now |
The issue is that you are logging those values. Because they are logged to the devtools when you are inspecting the server, they can't be GCed. Removing your |
omg... okay never thought about that... true... thanks for pointing that out! |
Here's a reproduction with Steps to reproduce:
|
I will have to take a deeper look later this month or in October. Feel free to take a deeper look in the meantime |
hey guys, sorry the leak i had in my bigger project was in nuxt-booster, it is duplicating the pinia store on each request (the snapshot looked like the one in the reproduction with the console.log ;) ), so i thought it would have to do something with pinia ;) ! see here: |
It looks like the memory leak is caused by this: pinia/packages/pinia/src/createPinia.ts Line 61 in df80a5e
Here is how it looks in dist files: if ((((process.env.NODE_ENV !== 'production') || (typeof __VUE_PROD_DEVTOOLS__ !== 'undefined' && __VUE_PROD_DEVTOOLS__)) && !(process.env.NODE_ENV === 'test')) && typeof Proxy !== 'undefined') {
pinia.use(devtoolsPlugin);
} After commenting out |
That's interesting. Devtools shouldn't be use in production besides for inspection, so it's expected to remove that part when building for production. Usually, the code is stripped out when bundling for production. I tested with CJS and esm and it seems that the memory leaks are internals (weird) when using |
Reproduction
https://github.com/dissy123/nuxt-pinia-memory-leak
Steps to reproduce the bug
The Repository i posted is just a blank Nuxt3 Project, i have added a Pinia Store like in the Documentation here:
https://nuxt.com/docs/getting-started/state-management
Have i done something wrong? Or is this a memory leak?
The Strings from the json objects are stored each request in the HEAP but not deleted again.
I tried it without the Code of the Store and no memory leak happens.
Sorry i am a little bit confused already hunting this for a few weeks now.
When you comment out the line in app.vue
await useAsyncData("todos", () => store.fetchIconsData());
no memory leak is happening!
Expected behavior
no memory leak
Actual behavior
Additional information
No response
The text was updated successfully, but these errors were encountered: