具有大数据收集的ngredux状态,内存问题 [英] ngredux state with big data collection, memory concerns

查看:41
本文介绍了具有大数据收集的ngredux状态,内存问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在为Angular应用实现ngRedux.一切都很好,但是我担心的是:内存使用情况,尤其是对于移动设备.

We are implementing ngRedux for our Angular app. It all works nicely however I have on concern: memory usage, especially for mobile.

我们的商店状态对象如下:

Our stores state object looks like this:

{
  leads : [],
  filters: [],
  applictionStatuses: [],
}

假设我们的用户在潜在客户列表中选择一个日期过滤器,它将从我们的API中抓取30.000个潜在客户(例如,全年).

Let's say on of our user selects a datefilter in the list of leads which will grab 30.000 leads from our API (a whole year for example).

据我了解,redux,状态对象将被克隆,然后下一个对象看起来像

As far as I understand redux, the state object will be cloned and then next object will look like

{
  leads : [ {object}, {object} ...],
  filters: [ dateRange: { start: {date}, end: {end} }],
  applictionStatuses: [],
}

处于当前状态的Leads对象将保存30.000条记录.否,当用户更改日期过滤器时,它将更新状态并使用新的日期过滤器创建一个新的状态.它将获取或多或少的记录,并将其转化为潜在客户.

The leads object in the current state will hold 30.000 records. No when the user changes the date filter, it will update the state and create a new one with the new date filter. It will grab more or less records and at that into leads.

理论上,状态对象看起来像:

Theoretically the state object could look like:

{
   leads : [ {object} ... times 40.000 ],
   filters: [ dateRange: { start: {date}, end: {end} } ],
   applictionStatuses: [],
}

这不是说此时,在内存中将存储3种状态,总共0 + 30.000 + 40.000引线= 70.000引线在内存中.状态的任何进一步变化都会重复该状态以及潜在客户.

Wouldn't this mean that at this time, in memory there would be 3 states stored with a total of 0 + 30.000 + 40.000 leads = 70.000 leads in memory. Any further change in state would duplicate the state and the leads on and on.

直到执行提交并压缩状态之前,我才会为潜在客户记录占用大量内存.

Only until I do a commit and squash the states, I would be occupying a lot of memory for lead records.

我的推理中是否有错误,还是redux不可避免的事情?

Is there a mistake in my reasoning or is this something that is inevitable with redux?

我们可以决定将Leads从Redux存储区中取出或放在单独的存储区中,以使所有Leads对象的状态对象不多.

We could decide to take the Leads out of the redux store or put in a separate store so that there are not as many state objects with all those lead objects.

对任何人的意见或合并都非常感兴趣.

Very much interested in anyones opinion or consolidation.

欢呼

推荐答案

否.Redux不会在生产中将先前的状态树保留在内存中.在 Redux和所有应用程序状态.

No. Redux does not keep previous state trees in memory in production. See my comment at Is there any way to "commit" the state in Redux to free memory? for more info, as well as similar related answers at Can a Redux store lead to a memory leak? and Redux and ALL the application state .

这篇关于具有大数据收集的ngredux状态,内存问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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