vuejs / vuex

šŸ—ƒļø Centralized State Management for Vue.js.
https://vuex.vuejs.org
MIT License
28.4k stars 9.57k forks source link

Memory leak on a trivial app #1934

Closed Kasheftin closed 3 years ago

Kasheftin commented 3 years ago

Version

4.0.0

Reproduction link

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

Steps to reproduce

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

Good catch!

Akryum commented 3 years ago

Vuex 4 has outdated devtools code form Vuex 3.

1949

kiaking commented 3 years ago

This should be fixed on Vuex 4.0.1 with the correct new Devtools support šŸ‘

gdabs commented 3 years ago

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

m00nk commented 3 years ago

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

stauren commented 2 years ago

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

gdabs commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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

stauren commented 2 years ago

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 commented 2 years ago

Using devtools: false solved the problem for me

andoniabedul commented 1 year ago

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