Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

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;
});
— asked June 4th 2010 by Gaurav Srivastva
1 Comment
  • Can we take a look at your database logic? That might be at issue here also.

    — commented June 4th 2010 by Kevin Whinnery

7 Answers

  • duplicate

    — answered June 4th 2010 by Dan Tamas
    permalink
    0 Comments
  • duplicate

    — answered June 4th 2010 by Dan Tamas
    permalink
    0 Comments
  • 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

    — answered June 4th 2010 by Dan Tamas
    permalink
    0 Comments
  • 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?

    — answered June 4th 2010 by Gaurav Srivastva
    permalink
    0 Comments
  • 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?

    — answered June 4th 2010 by Gaurav Srivastva
    permalink
    0 Comments
  • Looks like titanium SDK becomes non-responsive if the APP does a lot of logging.

    Is there a solution to this?

    — answered June 4th 2010 by Gaurav Srivastva
    permalink
    0 Comments
  • I have found the suds code to be very slow. Ended up using JSON for web service requests. Much much quicker.

    — answered August 5th 2011 by Marc Wickens
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.