Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vuex store data always reside in memory?

Tags:

vue.js

vuex

First of all, I would appreciate your understanding of my poor English. I wonder if Vuex's store data always resides in memory.

Let me explain with an example. When entering page A, we received a list from the server and implemented it to be stored on the store. Does this mean that when I enter page A and move to page B, the list of A will remain in memory even though it is not used?

Doesn't this cause memory overflow in very large applications?

like image 423
kkd927 Avatar asked Jun 20 '18 05:06

kkd927


People also ask

Where does Vuex store the data?

Vuex is a library that stores data in a Vuex store, which acts as the source of data on states in a Vue application. This store contains a global state (set of properties) and functions (getters, actions and mutations) used to read and alter the state.

Is Vuex store persistent?

A Typescript-ready Vuex plugin that enables you to save the state of your app to a persisted storage like Cookies or localStorage.

Is Vuex store immutable?

In Redux state is always immutable, while in Vuex committing mutation by the store is the only way to change data.


1 Answers

The entire page state (including the DOM and Javascript/Vuex data) will remain in memory provided that a full page reload did not occur (which would be the case if you're using vue-router). This is called a Single Page Application (SPA).

In a SPA, you need to ensure that you drop any references (e.g. set to null) to large objects and arrays when they are no longer needed so that the memory can be freed by the garbage collector.

like image 72
Decade Moon Avatar answered Oct 12 '22 10:10

Decade Moon