ASIHTTPRequest: Potential memory in EditSiteViewConroller leak

  1. Konstantin Kovshenin
    Jul 14, 2011, 8:53 AM

    Hey there, I really apologize if I got this wrong, but I think that there's a memory leak in EditSiteViewController.m on line 300:

    The ASIHTTPRequest object is set the alloc message but never receives a release or autorelease message. Unfortunately I was unable to test this out with Instruments since the app just crashes when profiled (although works fine when simply running) but I did test it out in my own application where I use ASIHTTPRequest to grab thumbnail images from my blog. Had it leaking like crazy until I added an [request release] right after startAsynchronous.

    Also I'm not sure whether the autorelease pool is necessary there, I don't see any allocations and autoreleases to be drained by the pool so it might be redundant.

    I also looked for other places and spotted the usage of [ASIHTTPRequest alloc] and found another potential leak in WPDataController. Let me know if you want me to test this out, I can submit a patch to fix them both.

    ~ Konstantin

  2. You're right, thanks. I can fix that one, but patches are very welcome :)

    The autorelease pool is needed since that method is called on a background thread. The strings used on urlToValidate are autoreleased and should be handled by an autorelease pool.

    The crash when profiling is really weird, and I haven't experienced it. Can you get a crash report for that?

  3. Konstantin Kovshenin
    Jul 14, 2011, 1:49 PM

    Opened a trac ticket right here trying to get a crash report from Instruments, I'm quite new to this so hang in there ;)

  4. Konstantin Kovshenin
    Jul 14, 2011, 2:16 PM

    Okay got some more info. It's working fine on the 4.3 simulator but crashes when I launch 4.2 for leaks. The activity monitor works though and seems like all the other modules from the library too. As soon as I drop the Allocations module to the list the app runs for 4-5 seconds and then crashes, can't seem to find any crash report.

    Anyways, I did the leaks profiling on 4.3 so yeh, there was an ASIHTTPRequest leak every time you add a new site, worth around 1kb. I've done it three times and here's the result , so the patch I submitted got rid of that, hurray!


  5. I applied your patch :)

    As for the crash report, it should be in Xcode's organizer: Devices -> <device_name> -> Device Logs

  6. Thanks for contributing!

  7. Konstantin Kovshenin
    Jul 15, 2011, 3:03 PM

    mrroundhill, no problem

    Jorge, thanks for the props. I can't find the iOS simulator in the devices section, only physical devices. The device logs section (not under devices) shows some logs, not sure where they're from, but WordPress is not listed in the applications list. I'd test it on my real devices, but they're both 4.3 and above and I'm having the crash with Instruments on 4.2.


Topic Closed

This topic has been closed to new replies.

About this Topic