Firebase .on()侦听器会导致Cordova iOS应用崩溃 [英] Firebase .on() listener causes Cordova iOS app crash
问题描述
var ref = new Firebase('url-to-firebase-leaf-node-with -4000儿');
ref.on(child_added,function(child,prev){
console.log(here);
});
部署到iPhone。应用程序崩溃,Xcode引用以下内容:
$ b $ p code WebThread(7):EXC_BAD_ACCESS(code = 1,address = 0xbbadbeef)里面的 bmalloc :: VMHeap :: grow()
。
如果我这样做: / p>
这显然是一个内存问题,但是如何解决呢?从4000个子节点中抽取1.5Mb的数据,我不会想象这应该占用所有可用的内存。请避免不提取所有数据的建议 - 应用程序需要所有的数据,并在Android上正常工作。 非常有表现力应用程序耗尽内存。 Firebase SDK使用您的订阅来构建数据库的内存镜像。即使您的 因此,您应该考虑对订阅使用限制,引入分页,或者如果数据库适合您的域模型,则应该重新构建数据库。 I have made a blank, brand new Cordova app (-v 6.3.1), and built for iOS. The app does nothing except the following: Deploy to iPhone. The app crashes, and Xcode cites the following: If I do this rather: This is clearly a memory problem, but how can it be resolved? With 1.5Mb of data being pulled down from 4,000 child nodes, I wouldn't have imagined this should be using up all available memory. Please avoid suggestions of not pulling all the data - the app needs all the data and works fine on Android. The native crash is pretty expressive. The application runs out of memory. The Firebase SDK builds an in-memory mirror of the database using your subscriptions. Even if your Therefore you should consider using limits on your subscription, introducing pagination, or even restructuring the database if it fits your domain model. 这篇关于Firebase .on()侦听器会导致Cordova iOS应用崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! var ref = new Firebase('url-to-firebase-leaf-node-with-100-children'); $ c $那么应用程序不会崩溃。
child_added
回调函数对子快照没有任何作用,这个内部树也使用内存来存储节点下的所有数据。
var ref = new Firebase('url-to-firebase-leaf-node-with-4000-children');
ref.on("child_added", function(child, prev) {
console.log("here");
});
WebThread (7): EXC_BAD_ACCESS (code=1, address=0xbbadbeef)
inside of bmalloc::VMHeap::grow()
.var ref = new Firebase('url-to-firebase-leaf-node-with-100-children');
then the app doesn't crash.child_added
callback does not do anything with the child snapshots, this internal tree uses memory for all the data under the node.