views:

48

answers:

1

Instruments is telling me that this code leaks. Where? Do I have to release conn?

- (void)loadFeatureXML:(id<BPLFeatureLoaderDelegate>)delegate {

    _delegate = delegate;

    NSURLConnection *conn;
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.myxmlfeed"]];
    if ([NSURLConnection canHandleRequest:request]) {   
        conn = [NSURLConnection connectionWithRequest:request delegate:self];
        if (conn) {
        self.featureXMLData = [NSMutableData data];
        }
    } 
}
+1  A: 

My best guess is that you're leaking the delegate; why not:

self._delegate = delegate;

Like you have below for self.featureXMLData?

Carl Norum
That causes an error, since I have no setter for _delegate.
Don Wilson
But if you overwrite that pointer without sending it a `release` or `autorelease` message, how does the system know to deallocate the old one? I guess without seeing other code that sets `_delegate` it's hard to tell - I don't see any other problems leaping out.
Carl Norum
Further, if you *do* have an explicit (ie non-synthesized) setter for featureXMLData it should be checked to make sure it's doing the right retain/release thing.
nall