Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4624510
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:08:24+00:00 2026-05-22T03:08:24+00:00

I am running Instruments to find the memoryleaks in my iPhone app. As you

  • 0

I am running Instruments to find the memoryleaks in my iPhone app.

As you can see on the screenshot below, I get some weird memory leaks, from some Foundation objects.

Screenshot form Instruments

The ones that bother me the most are the one that should be released “automatically” if I understood right. Such as: NSPredicate predicateWithFormat, NSKeyedUnarchiver unarchiveObjectWithData, and so…

Here a screenshot with more info for the NSPredicate one:
enter image description here

Can you please help me to understand what ma I doing wrong?

In the code I am simply doing that:

NSPredicate *basePredicate = [NSPredicate predicateWithFormat:@"ANY fcLists IN %@", listsIds];

NSEntityDescription *entity = [NSEntityDescription entityForName:@"Item" inManagedObjectContext:self.context];
[self.fetchRequest setEntity:entity];

// Load the list of new items
NSPredicate *addedPredicate = [NSPredicate predicateWithFormat:@"fcStatus = -2"];
NSPredicate *predicate = [NSCompoundPredicate andPredicateWithSubpredicates:[NSArray arrayWithObjects:basePredicate, addedPredicate, nil]];
[self.fetchRequest setFetchLimit:self.nbOfNewItems];
[self.fetchRequest setPredicate:predicate];
tmp = [self.context executeFetchRequest:self.fetchRequest error:&error];

so I shouldn’t have to release predicate right? Anyway I tried and it makes my code to crash…

Thank you in advance for your help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T03:08:25+00:00Added an answer on May 22, 2026 at 3:08 am

    The retain/release model is not like (for instance) malloc/free. It isn’t enough to balance your object creation with a release, or to use a method that returns an autoreleased objects. Every retain on an object must be balanced with a release. If you miss just one, the object is leaked. Instruments points out where the object was created, but not where it was leaked. Instruments points out each retain, but does not (and can not) point out which retain is not properly balanced.

    You didn’t specify what was actually leaking, so I’ll have to give a generic example based on your code.

    Let’s assume basePredicate was leaking:

    1. This simplest case for basePredicate leaking is that you simply haven’t called release on it. In this case, though, you’re creating it with a method that returns an autoreleased object.
    2. The next possibility is that you’re giving some other object a share of ownership in basePredicate (i.e. it calls retain). That object isn’t releasing it.
    3. The next possibility is that you’re giving some other object a share of ownership in basePredicate, as above, but that object does release it. It’s possible that object hands basePredicate off to some other object that claims ownership of it by retaining it.
    4. Next, it’s possible that the object that you’ve given ownership of is itself being leaked.
    5. There are very nearly an infinite number of permutations of the last three scenarios.

    If this sounds horrible, it kind of is. But the fix is actually simple: Make sure every time your code claims ownership of an object with retain (or assignment to a property with retain), it has a corresponding yield of ownership, in the form of a release or autorelease (or assignment of nil to the property).

    In the past, when I’ve had a leak I just can’t find, I’ve found the best thing to do is study which objects leak and identify what (if any) relationship they have. Then I go through my code and look for objects I haven’t released.

    Also, if you haven’t yet, start using the static analyzer. It can’t find all problems like this, but when it does find one you’ll save a lot of time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm running leaks through Instruments on my iPhone app and I'm seeing a lot
After running the Leaks Instruments on an app that I am developing, I see
Running my app in the simulator under Instruments to check for memory leaks, it
When profiling my app with Instruments (looking for memory leaks), I get extremely different
Can somebody help me trace these CoreVideo memory leaks when running Instruments in XCode?
Running Instruments on my iPad app found 2 leaks, except I cannot understand where
I am running my iPhone App on the simulator and looking for leaks using
I'm trying to resolve a memory leak but I can't find any solution. Instruments
so when i'm running my app using XCode and I can see that my
I am new to iPhone programming, and am running my app against the Leaks

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.