【发布时间】:2016-01-20 16:03:15
【问题描述】:
我目前正在尝试创建一个从 NSString 进行大量 json 序列化的函数。
NSArray* array = nil;
NSError* error = nil;
for (NSObject* obj in otherArray) {
array = [NSJSONSerialization JSONObjectWithData:[obj.json dataUsingEncoding:NSUTF8StringEncoding] options:kNilOptions error:&error];
// I'm using array here .. and then i don't need it anymore
}
这里我的 otherArray 可能非常大,而且 obj.json 也是。
但一段时间后,由于内存问题 (> 1GB),应用程序崩溃了。 似乎我的数组在 for 循环中永远不会被释放,因为当我评论该行时,我没有收到任何错误.. 如何使用 ARC 释放内存?
谢谢
【问题讨论】:
标签: objective-c for-loop memory nsarray nsjsonserialization