使用Cordova加载大型数据集时是否可以避免OOM? [英] Is it possible to avoid OOM when loading a large data set using Cordova?
问题描述
我正在使用一个Phonegap应用程序,该应用程序主要处理来自Firebase的小型JSON数据集,并存储在本地存储器以及JavaScript变量中。
I'm working on a Phonegap app that mostly deals with small JSON data sets coming from Firebase and being stored in local storage as well as into a javascript variable.
偶尔,虽然我需要处理更大的JSON数据集(> 2Mb)。发生这种情况时,我的设备的内存使用量大幅增长,同时从Firebase中提取数据并最终导致应用程序崩溃。
Occasionally though I need to handle larger JSON data sets (> 2Mb). When that happens, my device's memory usage grows hugely while pulling the data from Firebase and eventually crashes the application.
我在我的电脑上运行Chrome,并观察内存使用情况在检索数据时可上至〜2.5Gb 。一旦所有数据被检索,内存使用率就会下降到正常水平。
I ran it in Chrome on my computer and watched the memory usage go up to ~2.5Gb while retrieving the data. Once all the data was retrieved, the memory usage dropped way down to normal levels.
有没有人遇到这个问题或知道一个方法吗?
Has anybody else encountered this problem or know of a way around it?
推荐答案
您需要对数据进行分区
Firebase说
有关分块数据和创建大数据备份的更多信息,请参阅REST API的查询参数。一起使用,startAt,limitToFirst和shallow = true参数可用于为任何数量的数据建立索引键,并在可管理的段中检索它们。
For more information about chunking data and creating backups of big data, see the REST API's query parameters. Used together, startAt, limitToFirst, and shallow=true arguments can be used to index keys for any amount of data, and retrieve it in manageable segments.
https://www.firebase .com / docs / rest / guide / retrieval-data.html#section-rest-queries
这篇关于使用Cordova加载大型数据集时是否可以避免OOM?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!