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 663439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:29:23+00:00 2026-05-13T23:29:23+00:00

I am having a specific leak that I can’t seem to dig to the

  • 0

I am having a specific leak that I can’t seem to dig to the bottom of, cause my search always ends up in some Apple libraries. Any help from some veterans at dealing with this would be appreciated.

Here is the relevant source code: (leak indicated with a comment)

- (void)viewDidLoad {
//[super viewDidLoad];

NSManagedObjectContext *context = [(iEatAppDelegate*)[[UIApplication sharedApplication] delegate] managedObjectContext];

addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:creator action:@selector(launchCreatorWindow)];
self.navigationItem.rightBarButtonItem = addButton;

NSFetchRequest *fetReq = [[NSFetchRequest alloc] init];
[fetReq setEntity:[NSEntityDescription entityForName:entityName inManagedObjectContext:context]];
NSError *e = nil;

NSArray *temp = [context executeFetchRequest:fetReq error:&e];  
//leaking here according to performance tool

self.tableObjects = [[NSMutableArray alloc] initWithArray:temp];

if (e) {
    NSLog(@"%@, %@", e, [e description]);
}
[fetReq release];
}

I tried releasing temp, but it crashed with the EXC_BAD_ACCESS which i believe means it is autoreleased already.

The leaks performance tool says it is a Category: CFArray (store-deque) Event: Malloc
also says my library is responsible. This is the stack trace, number 8 being my viewDidLoad frame:

0 CoreFoundation __CFAllocatorSystemAllocate
1 CoreFoundation CFAllocatorAllocate
2 CoreFoundation _CFAllocatorAllocateGC
3 CoreFoundation _CFArrayReplaceValues
4 CoreFoundation CFArrayReplaceValues
5 CoreFoundation -[__NSPlaceholderArray initWithObjects:count:]
6 CoreFoundation -[NSArray initWithArray:copyItems:]
7 CoreFoundation -[NSArray initWithArray:]

This one really has me stuck, any help is greatly appreciated.

  • 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-13T23:29:23+00:00Added an answer on May 13, 2026 at 11:29 pm

    This causes your leak:

    self.tableObjects = [[NSMutableArray alloc] initWithArray:temp];
    

    You create an array with a retain count of 1, then you use self.tableObjects which (if that property is marked as retain) brings the count up to 2.

    Then in dealloc when you release the array the count is back down to 1, not 0 – so the array is never released.

    Instead, just do this:

     self.tableObjects = [NSMutableArray arrayWithArray:temp];
    

    That returns an autoreleased array, so the eventual retain count will be only 1.

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

Sidebar

Related Questions

I'm having a specific problem that I'd love some insight on. Here is my
im having some difficulty trying to pull out a specific value from a cookie.
How i can select each element having a specific class name inside a parent
Is there a way I can delete all files from svn having a specific
I am trying to prevent usernames from having specific characters so they can be
I'm having a very specific problem so I hope someone can help. I'm building
I'm having a build problem with a specific file that I'm not being able
I am having a very specific problem in JQuery The code below is used
I'm having a very specific bug in my iPhone application. I'm setting two images
I'm having a Firefox-specific issue with a script I wrote to create 3d layouts.

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.