• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Memory management about async object
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Memory management about async object


  • Subject: Re: Memory management about async object
  • From: ico <email@hidden>
  • Date: Tue, 8 Feb 2011 02:06:50 +0800

Hi All,

What if the handler retain itself, and then will perform some
NSURLConnection tasks, that will async download some data, and receive some
messages as a delegate by implementing
connection:didReceiveResponse
connection:didReceiveData
connection:didFailWithError
connection:didFinishLoading

when the application call the cancel method of NSURLConnection, no chance to
autorelease itself because those delegate methods will not have a chance to
be called as the official document stated:

Cancels an asynchronous load of a request.

- (void)cancel

*Discussion*

Once this method is called, the receiver’s delegate will no longer receive
any messages for this NSURLConnection.
Will this cause memory leak?


On Sun, Jan 2, 2011 at 12:50 AM, Steve Sisak <email@hidden> wrote:

> There's some good information on this in TechNote 2009
>
> <http://developer.apple.com/library/ios/#technotes/tn2009/tn2109.html>
>
> Also, here is some sample code you might find very helpful:
>
> <http://developer.apple.com/library/mac/#samplecode/LinkedImageFetcher/>
>
> as it does almost what you're describing.
>
> HTH,
>
> -Steve
>
>
>
>
> At 5:28 PM +0800 12/28/10, ico wrote:
>
>> Hi Stephen,
>>
>> Thanks for your reply, so there is no any perfect solution for this kind
>> of
>> problem?
>> And can you give me a specific example to demonstrate why why it is not
>> safe
>> to
>> release these async objects inside a callback method and why not safe to
>> autorelease it?
>> Thanks.
>>
>


--
==========================
Life isn't about finding yourself.
Life is about creating yourself.
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: NSDocument Question
  • Next by Date: Re: NSDocument Question
  • Previous by thread: Re: Composing an NSImage to print
  • Next by thread: NSDrawer dealloc causes kCGErrorIllegalArgument
  • Index(es):
    • Date
    • Thread