As of April 12th, you must go to Progress SupportLink to create new support cases or to access existing cases. Please, bookmark the SupportLink URL and use the new portal to contact the support team.
Titanium -- Kinvey queries slower after each save -- Memory Leak?
a
adampax
started a topic
over 8 years ago
We have an app that sometimes needs to save several hundred entities at a time. The Kinvey library doesn't appear to support the saving multiple entities on a single query, so we must do a Kinvey.DataStore.save for each entity.
I have found that the response time for each 'batch' of saves gets slower each time another round of saves is performed during the app session, to the point of the app not being usable. Example:
~~~
var startDate = new Date();
var promises = [];
Kinvey.DataStore.clean('speedTest')
.then(function(){
for(var i = 0; i var p = Kinvey.DataStore.save('speedTest', {
Running this test several times on Simulator gives me the following:
~~~
[INFO] : 200 queries completed, test time: 5746
[INFO] : 200 queries completed, test time: 7282
[INFO] : 200 queries completed, test time: 6983
[INFO] : 200 queries completed, test time: 12533
[INFO] : 200 queries completed, test time: 13453
[INFO] : 200 queries completed, test time: 15735
[INFO] : 200 queries completed, test time: 17658
[INFO] : 200 queries completed, test time: 20065
[INFO] : 200 queries completed, test time: 22759
[INFO] : 200 queries completed, test time: 24716
[INFO] : 200 queries completed, test time: 26803
~~~
After the initial query of 5.7 seconds, 3 rounds later, the speed doubles. 10 rounds later, it takes 5 times longer to do the same batch of queries.
If I modify the queries to use `offline:true` and relaunch the app, the query times are more consistent:
~~~
[INFO] : 200 queries completed, test time: 4303
[INFO] : 200 queries completed, test time: 4433
[INFO] : 200 queries completed, test time: 6594
[INFO] : 200 queries completed, test time: 5247
[INFO] : 200 queries completed, test time: 4470
[INFO] : 200 queries completed, test time: 4623
[INFO] : 200 queries completed, test time: 5626
[INFO] : 200 queries completed, test time: 4781
[INFO] : 200 queries completed, test time: 4820
[INFO] : 200 queries completed, test time: 4889
[INFO] : 200 queries completed, test time: 5384
[INFO] : 200 queries completed, test time: 6221
~~~
This would indicate an issue in the library's synchronization functionality, and while [monitoring the allocations via Instruments](http://docs.appcelerator.com/titanium/3.0/#!/guide/Managing_Memory_and_Finding_Leaks-section-29004941_ManagingMemoryandFindingLeaks-MonitoringallocationsoniOS) I see that `TiNetworkHTTPClient` objects are never released. Each time the queries are run, the Persistant count increases by 200: 1 for the DataStore.clean and 199 for the DataStore.saves.
[More info on Managing Memory in JavaScript and Titanium](http://docs.appcelerator.com/titanium/3.0/#!/guide/Managing_Memory_and_Finding_Leaks)
As I mentioned to you privately via email: We are currently treating this as a high priority bug and will be providing updates in this thread as they become available.
Thank you for the wonderful debugging / bug reporting.
a
adampax
said
over 8 years ago
Thanks Damien. Let me know if you want to look at my test app.
Damien Bell
said
over 8 years ago
Adam,
Our engineers may want to have a look at that in the coming days (realistically next Monday / Tuesday look promising).
I will be in touch, thanks,
A
Aaron Saunders
said
about 8 years ago
was this issue ever resolved? Thanks... sorry I am a bit late to the party
Damien Bell
said
about 8 years ago
Aaron:
It has not yet been resolved. It is something that we have began working on internally at this time but don't yet have a fix for.
adampax
I have found that the response time for each 'batch' of saves gets slower each time another round of saves is performed during the app session, to the point of the app not being usable. Example:
~~~
var startDate = new Date();
var promises = [];
Kinvey.DataStore.clean('speedTest')
.then(function(){
for(var i = 0; i
var p = Kinvey.DataStore.save('speedTest', {
foo: 'hi',
idx: i
});
promises.push(p);
}
return Kinvey.Defer.all(promises);
})
.then(function(res){
var stopDate = new Date();
console.log((res.length+1) + ' queries completed, test time: ' + (stopDate - startDate));
});
~~~
Running this test several times on Simulator gives me the following:
~~~
[INFO] : 200 queries completed, test time: 5746
[INFO] : 200 queries completed, test time: 7282
[INFO] : 200 queries completed, test time: 6983
[INFO] : 200 queries completed, test time: 12533
[INFO] : 200 queries completed, test time: 13453
[INFO] : 200 queries completed, test time: 15735
[INFO] : 200 queries completed, test time: 17658
[INFO] : 200 queries completed, test time: 20065
[INFO] : 200 queries completed, test time: 22759
[INFO] : 200 queries completed, test time: 24716
[INFO] : 200 queries completed, test time: 26803
~~~
After the initial query of 5.7 seconds, 3 rounds later, the speed doubles. 10 rounds later, it takes 5 times longer to do the same batch of queries.
If I modify the queries to use `offline:true` and relaunch the app, the query times are more consistent:
~~~
[INFO] : 200 queries completed, test time: 4303
[INFO] : 200 queries completed, test time: 4433
[INFO] : 200 queries completed, test time: 6594
[INFO] : 200 queries completed, test time: 5247
[INFO] : 200 queries completed, test time: 4470
[INFO] : 200 queries completed, test time: 4623
[INFO] : 200 queries completed, test time: 5626
[INFO] : 200 queries completed, test time: 4781
[INFO] : 200 queries completed, test time: 4820
[INFO] : 200 queries completed, test time: 4889
[INFO] : 200 queries completed, test time: 5384
[INFO] : 200 queries completed, test time: 6221
~~~
This would indicate an issue in the library's synchronization functionality, and while [monitoring the allocations via Instruments](http://docs.appcelerator.com/titanium/3.0/#!/guide/Managing_Memory_and_Finding_Leaks-section-29004941_ManagingMemoryandFindingLeaks-MonitoringallocationsoniOS) I see that `TiNetworkHTTPClient` objects are never released. Each time the queries are run, the Persistant count increases by 200: 1 for the DataStore.clean and 199 for the DataStore.saves.
[More info on Managing Memory in JavaScript and Titanium](http://docs.appcelerator.com/titanium/3.0/#!/guide/Managing_Memory_and_Finding_Leaks)