我是iphone開發人員和處理內存問題的新手。 我在學習,但有些東西對我來說依然神祕。內存泄漏問題
在以下情況下,「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];
我稍後在dealloc中釋放databaseName和databasePath。
您的幫助將非常感謝!
你的意思是你釋放'databasePath'和'databaseName'在你的dealloc方法中(你的最後一段說'databasePath'兩次)? – Rog 2011-03-25 09:59:04
在dealloc中我釋放databasePath和databaseName,沒錯。 – 2011-03-25 10:41:39