2010-11-27 84 views
0

下面的代碼段是從facebook.m文件:iPhone存儲器泄漏

-(void) requestWithMethodName:(NSString *)methodName 
       andParams:(NSMutableDictionary *)params 
      andHttpMethod:(NSString *)httpMethod 
       andDelegate:(id <FBRequestDelegate>)delegate { 
    NSString * fullURL = [kRestApiURL stringByAppendingString:methodName]; 
    [self openUrl:fullURL params:params httpMethod:httpMethod delegate:delegate]; 
} 

我已發現在fullURL初始化線100%的內存泄漏。我找不到解決方案..

如果有人知道它的解決方案,那麼請幫助我。

+0

請將您的代碼放入代碼片段中。 – TheSquad 2010-11-27 12:32:12

回答

0

這裏沒有泄漏。 stringByAppendingString:方法返回一個已經添加到autorelease池的新字符串。

0

儀器發現泄漏。它消失了,如果你擺脫在FBRequest類方法

+ (FBRequest *)getRequestWithParams:(NSMutableDictionary *) params 
         httpMethod:(NSString *) httpMethod 
          delegate:(id<FBRequestDelegate>) delegate 
         requestURL:(NSString *) url { 
    FBRequest* request = [[[FBRequest alloc] init] autorelease]; 
    request.delegate  = [delegate retain]; 
    request.url   = [url retain];   // <----- no leak if you don't retain url 
    request.httpMethod = [httpMethod retain]; 
    request.params  = [params retain]; 
    request.connection = nil; 
    request.responseText = nil; 

    return request; 
} 

的保留,但這裏一切似乎是確定的我,所以如果錯誤是在這裏或在器械我不能說。建議?