memory leak in readInBackgroundAndNotify
memory leak in readInBackgroundAndNotify
- Subject: memory leak in readInBackgroundAndNotify
- From: "Gurmit Teotia" <email@hidden>
- Date: Tue, 18 Apr 2006 20:25:07 +0530
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 memory
footprint 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