I am using Phonegap(Cordova) with "Good dynamics" in iOS. We have a table with 15 columns and need to insert more than 10000 to 200000 records based on condition at once.
But my app is getting crashed in iPAD when testing for more than 2000 records insertion.
I tried two different bulk insertions as in below link
Stack overflow answer(USING UNION ALL and COMMA separated INSERTS)
And also i tried both options:
1) Opening a transaction for each insert.
2) Multiple insertions in single transaction using for loop.
When tested in iOS simulator instruments both are taking more than 1GB memory when inserting more than 5000k records (i suspect which is causing issue).
Can any one suggest better solution for inserting multiple records when table have more columns with out any issues in IOS+SQLlite+PhoneGap+Good Dynamics
Sample code i used:
for(var j=0;j< bulkTransactions.length;j++){
(function(item,count){
db.transaction(function(tx){
if(item){
var insQuery= item;
tx.executeSql(insQuery, [],
function(tx,results){ //Success
if(count == bulkTransactions.length-1) {
if(callBackMethod != null)callBackMethod();
}
},
function(tx,e){
//Handle Error
}
);
}
});
}) (bulkTransactions[j],j);
}
The application is working fine in iOS simulator(even its showing 1GB memory usage) or Chrome Browser, the below image shows memory usage for 12000 records in iOS simulator: