Objective c 使用NSJSONSerialization后如何释放内存?

Objective c 使用NSJSONSerialization后如何释放内存?,objective-c,Objective C,我正在使用以下代码从我的iphone读取大型json文件(保存在iphone上的文件): dispatch_async(kBgQueue, ^{ // do something that takes a long time with receivedData here NSError* error; NSString *filePath = [self getFilePathWithName:LOCAL_JSON]; NSData

我正在使用以下代码从我的iphone读取大型json文件(保存在iphone上的文件):

dispatch_async(kBgQueue, ^{

        // do something that takes a long time with receivedData here
        NSError* error;
        NSString *filePath = [self getFilePathWithName:LOCAL_JSON];
        NSData *jsonData = [NSData dataWithContentsOfFile:filePath];
        NSDictionary *dict = (NSDictionary*)[NSJSONSerialization JSONObjectWithData:jsonData options:kNilOptions error:&error];

        dispatch_async( dispatch_get_main_queue(), ^{

            HideHUD;
            DLog(@"Reading done");
            ShowMemoryUsageWithTitle(@"after reading json");

            return;
        });

        dict = nil;
    });
在我完成读取之后,内存使用量增加了30 MB,例如,总内存使用量是60 MB。在那之后,我尝试再次阅读,是90MB,之后是120MB。 所以结论是记忆不是自动恢复的。每次我读的时候,记忆都在增加。我用的是ARC

读取完json文件后,如何释放内存

更新1: 试图在@autoreleasepool{}内进行“艰苦”工作,但内存使用情况没有改变

更新2: 尝试不使用调度\u异步

更新3:
我试着使用第三方库,但同样的问题。当我进行测试时,我只测试那个东西,而不是其他东西。

我想,你的问题在这里得到了回答:你看到你称之为
dict
的东西了吗?必须在某个地方发布(以及
jsonData
和可能的
filePath
)。如果您处于正常线程中,它将通过自动释放机制自动发生,但如果您正在运行自己的线程,则可能缺少合适的
@autorelease
边界。@HotLicks-尝试将“艰苦”工作放入自动释放池{},但内存使用情况没有改变。您究竟在“内部”放置了什么?@HotLicks-来自N错误*错误;还有整本字典