Re: Memory Leaks in CocoaEcho Sample
Re: Memory Leaks in CocoaEcho Sample
- Subject: Re: Memory Leaks in CocoaEcho Sample
- From: "Gary L. Wade" <email@hidden>
- Date: Wed, 22 Oct 2008 18:45:20 -0400
Then the bug is somewhere in your changes. The only thing you should do is remove the retain calls. If you also remove the release calls, you will still have the memory leaks.
Here's what openStreams should look like:
- (void)openStreams {
[inputStream setDelegate:self];
[outputStream setDelegate:self];
[inputStream scheduleInRunLoop:
[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
[outputStream scheduleInRunLoop:
[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
[inputStream open];
[outputStream open];
}
Here's what closeStreams should look like:
- (void)closeStreams {
[inputStream close];
[outputStream close];
[inputStream removeFromRunLoop:
[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
[outputStream removeFromRunLoop:
[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
[inputStream setDelegate:nil];
[outputStream setDelegate:nil];
[inputStream release];
[outputStream release];
inputStream = nil;
outputStream = nil;
}
>Hello,
>
>> To move beyond the memory leaks in an untouched version of
>> EchoClient, the only thing you need to do is remove the retain calls
>> in openStreams. The call to -[NSNetService
>> getInputStream:outputStream:] calls
>> CFStreamCreatePairWithSocketToNetService, which is a "create"
>> function.
>>
>> To verify this, the memory leak will be exacerbated every time you
>> select and deselect a service.
>
>I tried that, but the leaks are still there if I select and deselect
>the service several times. (Not the first time, but later on)...
>
>Jens
_______________________________________________
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