• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSPredicate predicateWithFormat:
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSPredicate predicateWithFormat:


  • Subject: Re: NSPredicate predicateWithFormat:
  • From: chaitanya pandit <email@hidden>
  • Date: Fri, 24 Oct 2008 00:33:17 +0530

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 (email@hidden)

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSPredicate predicateWithFormat:
      • From: Keary Suska <email@hidden>
References: 
 >NSPredicate predicateWithFormat: (From: chaitanya pandit <email@hidden>)
 >Re: NSPredicate predicateWithFormat: (From: Keary Suska <email@hidden>)

  • Prev by Date: Re: Controls disappearing from window during resize
  • Next by Date: Re: CGPoint wrapper?
  • Previous by thread: Re: NSPredicate predicateWithFormat:
  • Next by thread: Re: NSPredicate predicateWithFormat:
  • Index(es):
    • Date
    • Thread