Pax*_*nus 2 iphone xcode memory-leaks objective-c
我是iphone dev和处理内存问题的新手.我正在学习,但有些事情对我来说仍然很神秘.
在下面的例子中,"Instruments"的泄漏分析器说我在databasePath设置中有泄漏.我无法弄清楚为什么.
// databaseName and databasePath are properties of my class.
databaseName = [[NSString alloc] initWithString:@"sqlDbName.sql"];
NSArray *documentPaths = [[NSArray alloc] initWithArray:NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)];
NSString *documentsDir = [[NSString alloc] initWithString:[documentPaths objectAtIndex:0]];
// The problem is here :
databasePath = [[NSString alloc] initWithString:[documentsDir stringByAppendingPathComponent:databaseName]];
[documentPaths release];
[documentsDir release];
Run Code Online (Sandbox Code Playgroud)
我稍后在dealloc中发布了databaseName和databasePath.
非常感谢您的帮助!
| 归档时间: |
|
| 查看次数: |
135 次 |
| 最近记录: |