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 on a trivial app #1934

Closed
Kasheftin opened this issue Feb 15, 2021 · 14 comments
Closed

Memory leak on a trivial app #1934

Kasheftin opened this issue Feb 15, 2021 · 14 comments
Labels

Comments

@Kasheftin
Copy link

Version

4.0.0

Reproduction link

https://kasheftin.github.io/vuex4-memory-leak-example2/

Steps to reproduce

  • Load the app and use chrome devtools memory tab;
  • Take heap snapshot; The result is ~ 4.5 MB;
  • Press "Add" button. It will create 100 items in the store;
  • Take heap snapshot; The result is ~ 15.7 MB;
  • Press "Clear regular items" button. It will remove all items in the store;
  • Take heap snapshot; The result is still ~ 15.7 MB;
  • Add/remove items multiple times, notice the allocated space grows all the time;

What is expected?

There's exactly the same app for vue2.6 vuex3.4: https://kasheftin.github.io/vuex4-memory-leak-example1/
Exactly the same code gives the correct result there: memory is cleared up correctly there. It should be the same in vue3.0 vuex4.0.

What is actually happening?

Allocated memory is not cleared up in vue3.0 vuex4.0


vue2.6 vuex3.4 source code (working correctly):

https://github.com/Kasheftin/vuex4-memory-leak-example1

vue3.0 vuex4.0 source code (memory leak):

https://github.com/Kasheftin/vuex4-memory-leak-example2

@Kasheftin
Copy link
Author

That's vuex4 issue. If I replace vuex with just a plain array in data, everything works as expected (no memory leak):
Example 3 (vue3 without vuex): https://kasheftin.github.io/vuex4-memory-leak-example3/
Source code: https://github.com/Kasheftin/vuex4-memory-leak-example3

@Trinovantes
Copy link

Screenshot 2021-04-28 221836

If I'm reading this right, it seems the memory leak is caused by Vue Devtools chrome extension retaining a reference to the array. If I delete the extension, I can't reproduce the memory leak in your example2 url.

@Kasheftin
Copy link
Author

Good catch!

@Akryum
Copy link
Member

Akryum commented Apr 29, 2021

Vuex 4 has outdated devtools code form Vuex 3.

#1949

@kiaking
Copy link
Member

kiaking commented Jun 1, 2021

This should be fixed on Vuex 4.0.1 with the correct new Devtools support 👍

@kiaking kiaking closed this as completed Jun 1, 2021
@kiaking kiaking added the 4.x label Jun 1, 2021
@gdabs
Copy link

gdabs commented Aug 31, 2021

i update vuex to version v4.0.2 but memory leak persist in ssr
image

@m00nk
Copy link

m00nk commented Sep 26, 2021

I see the memory leaks in SSR (Quasar project). The leaks disappear when I disable vuex.

@stauren
Copy link

stauren commented Nov 24, 2021

also have the same memory leak issue in SSR using v4.0.2, please reopen this bug.

@gdabs
Copy link

gdabs commented Nov 24, 2021

also have the same memory leak issue in SSR using v4.0.2, please reopen this bug.

i have used createVuexStore in serverRender file to resolve this problem

@stauren
Copy link

stauren commented Nov 24, 2021

also have the same memory leak issue in SSR using v4.0.2, please reopen this bug.

i have used createVuexStore in serverRender file to resolve this problem

Can not find an API called createVuexStore. Where can find it?

@gdabs
Copy link

gdabs commented Nov 24, 2021

first, you should find where are your store established in, erery page should establish a unrelated strore

@stauren
Copy link

stauren commented Nov 24, 2021

first, you should find where are your store established in, erery page should establish a unrelated strore

In my case every SSR request create new vuex store, no store instance is reused, still have the leak. Think need an API to release or unload the Vuex instance.

@Carseason
Copy link

Using devtools: false solved the problem for me

@andoniabedul
Copy link

Thank you @Carseason we solved a huge problem of memory leak thanks to your comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants