【问题标题】:TWRequest leak in ARC projectARC 项目中的 TWRequest 泄漏
【发布时间】:2012-02-26 19:57:33
【问题描述】:

我创建了下面的函数,但是它似乎在 performRequestWithHandler 上泄漏。

- (void)getDataForRequest:(TWRequest *)postRequest withSelector:(SEL)selector {

if (twitterAccount != nil) {

    [postRequest setAccount:twitterAccount];

    [postRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error){

        id jsonResponse = nil;

        if (responseData) {
            NSError *jsonParsingError = nil;
            jsonResponse = [NSJSONSerialization JSONObjectWithData:responseData options:0 error:&jsonParsingError];
        }

        if (!jsonResponse) {
            NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSASCIIStringEncoding];
            jsonResponse = [NSDictionary dictionaryWithObjectsAndKeys:responseString, @"response", nil];
        }

        if (error != nil && ![jsonResponse objectForKey:@"error"]) {

            NSString *errorMessage = error.localizedDescription;
            jsonResponse = [NSDictionary dictionaryWithObjectsAndKeys:errorMessage, @"error", nil];

        }

        [self performSelectorOnMainThread:selector withObject:jsonResponse waitUntilDone:NO];                    


    }];
}

}

Backtrace 的泄漏:

泄漏对象 ---- # ---- 地址 ---- 大小 ---- 负责库 ---- 负责框架

XPCProxy ---- 1 ---- 0x2c6480 ---- 32 字节 ---- Accounts ---- -[ACOAuthSigner initWithAccount:]

NSArray ---- 1 ---- 0x2cf010 ---- 64 字节 ---- XPCObjects ---- -[XPCProxy restrictDecodingToWhitelistedClassNames:]

Malloc 128 字节 ---- 1 ---- 0x2d0650 ---- 128 字节 ---- libdispatch.dylib dispatch_queue_create$VARIANT$mp

Malloc 128 字节 ---- 1 ---- 0x2cf0f0 ---- 128 字节 ---- libdispatch.dylib dispatch_queue_create$VARIANT$mp

谢谢。

【问题讨论】:

  • 什么操作系统?你在用ARC吗?您是否尝试过在启用了僵尸的仪器上跑步?
  • 是的,我使用过启用了僵尸的乐器。我正在使用 iOS 5 和 ARC。谢谢。
  • 您找到解决方案了吗?

标签: objective-c ios automatic-ref-counting twrequest


【解决方案1】:

这是由 iOS 5.0 上 Apple 的 API 代码中的错误引起的,现在似乎已修复

【讨论】:

    猜你喜欢
    • 2017-03-18
    • 1970-01-01
    • 2012-12-09
    • 1970-01-01
    • 2012-05-17
    • 2012-04-03
    • 1970-01-01
    • 2012-09-14
    • 1970-01-01
    相关资源
    最近更新 更多