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:04:12 -0400
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.
>>
>
>Hello,
>
>> The retains in -openStreams are balanced by the releases in -
>> closeStreams. Similarly, the streams are retained/released in a
>> balanced fashion within the server. So, unless the server is never
>> shutting down, that isn't the source of your leak -- there must be
>> an unbalanced -retain coming from somewhere.
>>
>> The Leaks instrument can tell you where all -retain/-releases were
>> invoked from. You should see an unbalanced -retain.
>
>So I think now I got it, for example if there is a line 48 there
>should be another line -48, right? Then it's balanced, and it's not
>necessarily the last line?
>
>There are several leaks, and I think one unbalanced part should then
>be getinputstream:outputstream:, and -openstreams: Simply deleting the
>two retain lines in the openstreams: didn't work...
>
>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