• 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
Memory management problem in using of NSConnection
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Memory management problem in using of NSConnection


  • Subject: Memory management problem in using of NSConnection
  • From: email@hidden
  • Date: Fri, 30 Nov 2001 15:16:24 -0700

Hello all,
I got quite confused about memory management while using NSConnection.

I have a server application with a controller.m:
-(void)awakeFromNib
{
NSPort *receivePort = nil;
NSConnection *conn;

receivePort = [[NSMachPort alloc] init];
conn = [[NSConnection alloc] initWithReceivePort:receivePort sendPort:nil];
[conn setRootObject:self];

//[receivePort release];
//[conn release];
}

According to the memory management rule of cocoa, I think I should add [receivePort release]; [conn release]; to the function because I alloc them, but if I do so my client application can't work properly(without these two sentences, the client works well).

A client application with controller.m as follows:
-(void)awakeFromNib
{
NSPort *sendPort=nil;
NSConnection *conn;

sendPort = [[NSMachBootstrapServer sharedInstance] portForName:@"mytest" host:nil];
if(sendPort == nil)
{
exit(1);
}
conn = [[NSConnection alloc] initWithReceivePort:nil sendPort:sendPort];
proxyObj = nil;
proxyObj = [[conn rootProxy] retain];

[m_proxyObj setProtocolForProxy:@protocol(ServerProtocol)];
//[conn autoRelease];
}

Is there anything wrong? Should I add [conn autoRelease]; and [proxyObj release]; in my client application?

Thanks very much for any help!
Fei


  • Prev by Date: Re: File's Owner
  • Next by Date: Drawing NSImage in grayscale
  • Previous by thread: Number Formatting
  • Next by thread: Drawing NSImage in grayscale
  • Index(es):
    • Date
    • Thread