Reputation: 537
I have made a blank, brand new Cordova app (-v 6.3.1), and built for iOS. The app does nothing except the following:
var ref = new Firebase('url-to-firebase-leaf-node-with-4000-children');
ref.on("child_added", function(child, prev) {
console.log("here");
});
Deploy to iPhone. The app crashes, and Xcode cites the following:
WebThread (7): EXC_BAD_ACCESS (code=1, address=0xbbadbeef)
inside of bmalloc::VMHeap::grow()
.
If I do this rather:
var ref = new Firebase('url-to-firebase-leaf-node-with-100-children');
then the app doesn't crash.
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.
Upvotes: 0
Views: 314
Reputation: 5665
Before adding the child_added
listener, ensure that you have cached all of the data (through the aforementioned pagination technique, or otherwise).
Upvotes: 0
Reputation: 2896
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 child_added
callback does not do anything with the child snapshots, this internal tree uses memory for all the data under the node.
Therefore you should consider using limits on your subscription, introducing pagination, or even restructuring the database if it fits your domain model.
Upvotes: 2