Vuex 存储数据总是驻留在内存中? [英] Vuex store data always reside in memory?

查看:64
本文介绍了Vuex 存储数据总是驻留在内存中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我很感激你能理解我糟糕的英语.不知道Vuex的store数据是不是一直驻留在内存中.

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

让我用一个例子来解释.当进入页面 A 时,我们从服务器收到一个列表,并实现它存储在商店中.这是否意味着当我进入页面 A 并移动到页面 B 时,A 的列表即使没有使用也会保留在内存中?

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?

推荐答案

整个页面状态(包括 DOM 和 Javascript/Vuex 数据)将保留在内存中,前提是没有发生整页重新加载(这就是这种情况)如果您使用的是 vue-router).这称为单页应用程序 (SPA).

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).

在 SPA 中,您需要确保在不再需要大型对象和数组时删除对它们的任何引用(例如设置为 null),以便垃圾可以释放内存收集器.

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.

这篇关于Vuex 存储数据总是驻留在内存中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆