Re: memory leak in readInBackgroundAndNotify
Re: memory leak in readInBackgroundAndNotify
- Subject: Re: memory leak in readInBackgroundAndNotify
- From: "Gurmit Teotia" <email@hidden>
- Date: Wed, 19 Apr 2006 15:53:44 +0530
Could someone help me on this topic? Resending it again as I didn't get any
reply.
I would like as one more finding here, if I declare mData as instance
variable and try to print in message of button click then my application
crashes. It means it is released, but then why current count in ObjectAlloc
increase by one upon receiving the data?
Regards,
Gurmit
On 4/18/06, Gurmit Teotia <email@hidden> wrote:
>
> Hi All,
>
>
>
> I have created a GUI application in Cocoa. I'm using the NSFileHandle's
> readInBackgroundAndNotify method to read the data from socket. Data
> receiving method is something like this:-
>
>
>
> -(void) receivedData: (NSNotification *) notification
>
> {
>
> NSData *data=[[notification userInfo] objectForKey:
> NSFileHandleNotificationDataItem];
>
> NSString *mData=[NSString stringWithUTF8String:[ data bytes];
>
>
>
> .. do something with mData
>
>
>
> [fileHandle readInBackgroundAndNotify];
>
>
>
> }
>
>
>
> In above method "mData" is not released which results in increased memoryfootprint of application. I'm wondering in which autorelease pool "mData" is
> allocated? ObjectAlloc program is only showing one instance of
> NSAutoreleasePool.
>
>
>
> If I create a new NSAutoreleasePool object at entry point of method and
> release it at exit point then no memory leaks happen.
>
> Could any one please explain me this behaviour? I'm also new to Cocoa
> development.
>
>
>
> Regards,
>
>
>
> Gurmit
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden