Ah...

Thank you. I understand now.

James

On Mar 10, 2009, at 5:41 PM, Randall Meadows wrote:

On Mar 10, 2009, at 4:35 PM, James Cicenia wrote:

NSMutableArray *arraySubType = [[NSMutableArray alloc]init];

OK, this array, you *should* release, yes.

Then in a loop from the database I have:

while (sqlite3_step(statement) == SQLITE_ROW) {

if(![aDict objectForKey: [NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 1)]]){
        NSMutableArray *tmpArray = [[NSMutableArray alloc]init];
[aDict setValue:tmpArray forKey: [NSString stringWithUTF8String: (char *)sqlite3_column_text(statement, 1)]];
        [tmpArray release];
}
arraySubType = [aDict objectForKey: [NSString stringWithUTF8String: (char *)sqlite3_column_text(statement, 1)]];

You have now just overwritten the previous value of arraySubType, thus leaking it. You now have a handle to a completely different object, which is autoreleased. This is why when you do release it, you crash later.

If you do not use arraySubType between the alloc/init above and this line, then you do not need to alloc/init it, just declare it only.

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to