Re: Memory Leaks in CocoaEcho Sample
Re: Memory Leaks in CocoaEcho Sample
- Subject: Re: Memory Leaks in CocoaEcho Sample
- From: Jens Beuckenhauer <email@hidden>
- Date: Thu, 23 Oct 2008 07:05:20 +0200
Hello,
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;
}
I have done exactly what you wrote above in a freshly dezipped
CocoaEcho Project. Running it first with the retain and then without.
It didn't work. This morning, I tried it again and it worked?!? I
think I forgot to clean the build or something like that... Thanks for
your help
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