• 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 leak in readInBackgroundAndNotify
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: memory leak in readInBackgroundAndNotify


  • Subject: Re: memory leak in readInBackgroundAndNotify
  • From: "Gurmit Teotia" <email@hidden>
  • Date: Thu, 20 Apr 2006 12:35:34 +0530

I'm sorry. I think I have messed up the things. I would like to summarize my
problem again:

I have two methods in my application:



-(void) receivedData: (NSNotification *) notification

{

            NSData *data=[[notification userInfo] objectForKey:
NSFileHandleNotificationDataItem];

            NSString *mData=[NSString stringWithUTF8String:[ data bytes];



            .. do something with mData



            [fileHandle readInBackgroundAndNotify];


}
This method is called back as a notification by NSFileHandle whenever any
data arives on socket.

And another method which is the action for a NSButton:

-(IBAction) createString: (id)sender
{
      NSString *string=[[NSString alloc] initWithCString:"testing string"];
      NSString *capString=[string capitalizedString];

     [string release];

}

In method "receiveData" "mData" is never released. In ObjectAlloc program I
can verify that from "Instance Browser" and current count. On each read
operation a new "mData" instance is displayed in
ObjectAlloc.
While in "createString" method which is called on NSButton click "capString"
is never retained. It is released after event cycle.

Both "mData" and "capString" are autoreleased object so why is this
difference in behaviour?

I agree that "init...." message or nested autorelease pool solves the
problem. But I want to understand above behavior. As a newbie it is very
diffiecult to me to come to a conclusion that ObjectAlloc has a bug.
I'm using XCode 2.1 version on MAC OS X 10.4.

Thanks for everyone for giving your precious time.

Regards,
Gurmit



On 4/20/06, mmalcolm crawford <email@hidden> wrote:
>
>
> On Apr 19, 2006, at 11:07 PM, Gurmit Teotia wrote:
>
> > I'm sorry. I didn't get you. Is I'm not clear in explaining my
> > problem?
> >
>
> Correct.
> Please send any further clarifications to the list.
>
> mmalc
>
>
 _______________________________________________
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

References: 
 >Re: memory leak in readInBackgroundAndNotify (From: "Gurmit Teotia" <email@hidden>)
 >Re: memory leak in readInBackgroundAndNotify (From: Greg Herlihy <email@hidden>)
 >Re: memory leak in readInBackgroundAndNotify (From: "Gurmit Teotia" <email@hidden>)

  • Prev by Date: Re: Core Data SIGSEGV when opening an existing document
  • Next by Date: Re: Drawing order (was: Re: Any tricks to dragging an NSTableView?)
  • Previous by thread: Re: memory leak in readInBackgroundAndNotify
  • Next by thread: Best Cocoa Books
  • Index(es):
    • Date
    • Thread