memory leak + unresponsive iphone app
Hi,
I've created an iPhone app which connects to a server using SOAP and "suds.js" and fetches around 5000 user accounts at the rate 5 accounts per SOAP request per second.
The app works fine initially but becomes sluggish and the SDK becomes unresponsive.
One user account is around 3000 bytes in length. I'm invoking the following request 1000 times since it returns 5 contacts every time and store those contacts in the database.
How can I free these DOM objects as well as my converted objects in order to conserve memory? How can I monitor memory and CPU of the app in the SDK?
suds.invoke('GetContacts', callparams, function(xmlDoc)
{
if (xmlDoc != null) {
var results = xmlDoc.documentElement.getElementsByTagName('contact');
if (results && results.item.length > 0) {
var contacts = new Contacts(results);
if (!contacts.parse())
{
Ti.API.error('failed to parse XML response');
return;
}
storeContacts (contacts);
return;
}
Ti.API.error('Failed to get contacts from the response');
}
else
Ti.API.error('Failed to fetch contacts in the webservice');
return;
});
7 Answers
-
duplicate
-
duplicate
-
maybe declaring
var results, contacts;
outside the function as a global variable will help, it will use the same variable at each iteration.
or after you use it, simply set it to null, even if the error is triggered.
storeContacts (contacts); contacts = null; results = null;
let me know
-
That helps but now while the app is still responsive, the titanium SDK becomes unresponsive and I have to force-kill it.
Why would SDK become unresponsive?
-
That helps but now while the app is still responsive, the titanium SDK becomes unresponsive and I have to force-kill it.
Why would SDK become unresponsive?
-
Looks like titanium SDK becomes non-responsive if the APP does a lot of logging.
Is there a solution to this?
-
I have found the suds code to be very slow. Ended up using JSON for web service requests. Much much quicker.