Re: NSPredicate predicateWithFormat:
On Oct 23, 2008, at 1:03 PM, chaitanya pandit wrote: Well i could not find any explicit explicit alloc/init method for predicate, I am using Instruments to check for memory leaks, and it shows a memory leak with the array. You would use NSComparisonPredicate for explicit creation. Anyway, just because instruments says there is a leak, doesn't mean there really is a leak. It just thinks there *might* be a leak. Use object allocations to watch namesArray, and I bet you will see it being deallocated nice and neat. If not, then it means you aren't showing us all of the relevant code. On 23-Oct-08, at 11:33 PM, Keary Suska wrote: On Oct 23, 2008, at 11:05 AM, chaitanya pandit wrote: NSArray *namesArray = [NSArray arrayWithObjects:@Tom , @Matt , @Joe, nil]; NSPredicate *predicate = [NSPredicate predicateWithFormat: @Name IN %@, namesArray]; NSMutableArray *foundNames = [[arrayController arrangedObjects]filteredArrayUsingPredicate:predicate]; It works but he problem is that i have a memory leak over here, before creating the predicate, the retain count of namesArray is 1, but after i create the predicate it is 2 and in instruments i see a memory leak with the namesArray. There is no memory leak in the code you provided. Everything is autoreleased, and should be deallocated when the pool is drained. The NSPredicate is probably retaining its arguments, and it should release them when itself is released. To check this, use alloc/init for the predicate and explicitly release it before re-checking the retain count. Anyway, you shouldn't rely on retain count for memory-related issues, as you now see. Keary Suska Esoteritech, Inc. Demystifying technology for your home or business ___ 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 [EMAIL PROTECTED]
NSPredicate predicateWithFormat:
Hi list, I have an array controller that manages certain entities, each of the entity has an attribute Name now i want to search for entities with names from a given array, Say i have an array (namesArray) with contents Tom, Matt, Joe now what i do is, i create a predicate which will look for the names in the given array within all the entities present in the array controller, NSArray *namesArray = [NSArray arrayWithObjects:@Tom , @Matt , @Joe, nil]; NSPredicate *predicate = [NSPredicate predicateWithFormat: @Name IN %@, namesArray]; NSMutableArray *foundNames = [[arrayController arrangedObjects]filteredArrayUsingPredicate:predicate]; It works but he problem is that i have a memory leak over here, before creating the predicate, the retain count of namesArray is 1, but after i create the predicate it is 2 and in instruments i see a memory leak with the namesArray. Any idea what i'm doing wrong? Thanks Chaitanya ___ 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 [EMAIL PROTECTED]
NSPredicate predicateWithFormat:
Hi list, I have an array controller that manages certain entities, each of the entity has an attribute Name now i want to search for entities with names from a given array, Say i have an array (namesArray) with contents Tom, Matt, Joe now what i do is, i create a predicate which will look for the names in the given array within all the entities present in the array controller, NSArray *namesArray = [NSArray arrayWithObjects:@Tom , @Matt , @Joe, nil]; NSPredicate *predicate = [NSPredicate predicateWithFormat: @Name IN %@, namesArray]; NSMutableArray *foundNames = [[arrayController arrangedObjects]filteredArrayUsingPredicate:predicate]; It works but he problem is that i have a memory leak over here, before creating the predicate, the retain count of namesArray is 1, but after i create the predicate it is 2 and in instruments i see a memory leak with the namesArray. Any idea what i'm doing wrong? Thanks Chaitanya ___ 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 [EMAIL PROTECTED]
Re: NSPredicate predicateWithFormat:
On Oct 23, 2008, at 11:05 AM, chaitanya pandit wrote: NSArray *namesArray = [NSArray arrayWithObjects:@Tom , @Matt , @Joe, nil]; NSPredicate *predicate = [NSPredicate predicateWithFormat: @Name IN %@, namesArray]; NSMutableArray *foundNames = [[arrayController arrangedObjects]filteredArrayUsingPredicate:predicate]; It works but he problem is that i have a memory leak over here, before creating the predicate, the retain count of namesArray is 1, but after i create the predicate it is 2 and in instruments i see a memory leak with the namesArray. There is no memory leak in the code you provided. Everything is autoreleased, and should be deallocated when the pool is drained. The NSPredicate is probably retaining its arguments, and it should release them when itself is released. To check this, use alloc/init for the predicate and explicitly release it before re-checking the retain count. Anyway, you shouldn't rely on retain count for memory-related issues, as you now see. HTH, Keary Suska Esoteritech, Inc. Demystifying technology for your home or business ___ 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 [EMAIL PROTECTED]
Re: NSPredicate predicateWithFormat:
Well i could not find any explicit explicit alloc/init method for predicate, I am using Instruments to check for memory leaks, and it shows a memory leak with the array. On 23-Oct-08, at 11:33 PM, Keary Suska wrote: On Oct 23, 2008, at 11:05 AM, chaitanya pandit wrote: NSArray *namesArray = [NSArray arrayWithObjects:@Tom , @Matt , @Joe, nil]; NSPredicate *predicate = [NSPredicate predicateWithFormat: @Name IN %@, namesArray]; NSMutableArray *foundNames = [[arrayController arrangedObjects]filteredArrayUsingPredicate:predicate]; It works but he problem is that i have a memory leak over here, before creating the predicate, the retain count of namesArray is 1, but after i create the predicate it is 2 and in instruments i see a memory leak with the namesArray. There is no memory leak in the code you provided. Everything is autoreleased, and should be deallocated when the pool is drained. The NSPredicate is probably retaining its arguments, and it should release them when itself is released. To check this, use alloc/init for the predicate and explicitly release it before re-checking the retain count. Anyway, you shouldn't rely on retain count for memory-related issues, as you now see. HTH, Keary Suska Esoteritech, Inc. Demystifying technology for your home or business ___ 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 [EMAIL PROTECTED]