我正致力于Memory Fineturning,大多数问题都是在stackoverflow的帮助下解决的。但最后我在NSMutableArray初始化时遇到了严重的内存泄漏。
- (NSMutableArray *)children {
if (!_children) {
_children = [NSMutableArray new]; // <-- here is the memory leak
}
return _children;
}
此外还有声明
@property(强,非原子)NSMutableArray * children;
@synthesize children = _children;
各自的.h和.m文件......
Waht可能是问题......?
先谢谢你的努力...
更多信息......
- (id)init {
if (self = [super init]) {
[self setIsRoot:NO];
// [self setChildren:[NSMutableArray new]]; // <-- was before, but I moved to custom setter
}
return self;
}
- (id)initAsRoot
{
if (self = [self init]) {
self.level = -1;
self.index = -1;
self.isExpaned = YES;
self.value = @"Root";
self.isRoot = YES;
}
return self;
}