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

  • Home
  • SEARCH
  • 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 3357968
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:41:46+00:00 2026-05-18T02:41:46+00:00

i have leaks in this code. The performane tool leaks tell me that this

  • 0

i have leaks in this code. The performane tool leaks tell me that this is in this line:

NSArray *fakeData = [[NSArray alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"FakeData" ofType:@"plist"]];

I can’t find out what is going on. The plist that i am loading have 3 NSDictionary Elements, so same as leaks in screenshot. Each Dictionary has 3 strings.

The entire code:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
//Ładowanie danych
if (![[FlickrFetcher sharedInstance] databaseExists]) {
    NSArray *fakeData = [[NSArray alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"FakeData" ofType:@"plist"]];

    for (NSDictionary *element in fakeData) {
        //Wypełnianie CoreData danymi
        Photo *newPhoto = (Photo *)[NSEntityDescription insertNewObjectForEntityForName:@"Photo"
                                                            inManagedObjectContext:[[FlickrFetcher sharedInstance] managedObjectContext]];
        NSLog(@"Creating Photo: %@", [element objectForKey:@"name"]);
        [newPhoto setName:[element objectForKey:@"name"]];
        [newPhoto setImageURL:[element objectForKey:@"path"]];

        NSLog(@"Person is: %@", [element objectForKey:@"user"]);ŕŕŕ
        NSPredicate *predicate = [NSPredicate predicateWithFormat:@"name == %@", [element objectForKey:@"user"]];

        NSMutableArray *peopleArray = (NSMutableArray *)[[FlickrFetcher sharedInstance] fetchManagedObjectsForEntity:@"Person" 
                                                                                                   withPredicate:predicate];
        NSEnumerator *enumerator = [peopleArray objectEnumerator];
        Person *person;
        BOOL exists = FALSE;

        while (person = [enumerator nextObject]) {
            NSLog(@"Person is: %@", person.name);
            if ([person.name isEqualToString:[element objectForKey:@"user"]]) {
                exists = TRUE;
                NSLog(@"-- Person exists: %@", person.name);
                [newPhoto setOwner:person];
            }
        }

        if (!exists) {
            Person *newPerson = (Person *)[NSEntityDescription insertNewObjectForEntityForName:@"Person" 
                                                                    inManagedObjectContext:[[FlickrFetcher sharedInstance] managedObjectContext]];
            [newPerson setName:[element objectForKey:@"user"]];
            NSLog(@"Person created: %@", newPerson.name);
            [newPhoto setOwner:newPerson];
        }

        NSError *error;
        if (![[[FlickrFetcher sharedInstance] managedObjectContext] save:&error]) {
            NSLog(@"Unresolved error %@ %@", error, [error userInfo]);
            exit(-1);
        }

        [fakeData release];     
    }

}

//Person Navigation Controller
personNavigationController = [[UINavigationController alloc] init];
PersonListViewController *personListViewController = [[PersonListViewController alloc] initWithStyle:UITableViewStylePlain];
personListViewController.title = @"Contacts";
[personNavigationController pushViewController:personListViewController animated:NO];
[personListViewController release];

//Recent Photo Navigation Controller
recentPhotoNavigationController = [[UINavigationController alloc] init];
RecentPhotoViewController *recentPhotoViewController = [[RecentPhotoViewController alloc] init];
recentPhotoViewController.title = @"Recent";
UITabBarItem *item = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemRecents tag:1];
recentPhotoViewController.tabBarItem = item;
[item release];
[recentPhotoNavigationController pushViewController:recentPhotoViewController animated:NO];
[recentPhotoViewController release];

//Tab Bar Controller
tabBarController = [[UITabBarController alloc] init];
tabBarController.viewControllers = [NSArray arrayWithObjects:
                                    personNavigationController,
                                    recentPhotoNavigationController,
                                    nil];


[window addSubview:tabBarController.view];
[window makeKeyAndVisible];

return YES;

}

  • 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-18T02:41:47+00:00Added an answer on May 18, 2026 at 2:41 am

    It looks like your fakeData array is being released inside of the for loop, which seems problematic on several levels. You probably meant to release it when the loop has exited. From Leaks’ perspective, the for loop might never be entered, in which case the object would be leaked.

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

Sidebar

Related Questions

I have a process x that I want to check for leaks with valgrind
I have seen a similar line of code floating about in Apples code: (void)[[URLRequest
let's say I have this code in javascript: function doAnAjaxCall () { var xhr1
Can someone please tell me why this code is leaking? Instruments is showing several
I have somehow misconfigured fingers. This leads to a very annoying situation. I select
Per this helpful article I have confirmed I have a connection pool leak in
I have a huge web app that is having issues with memory leak in
I have a UIViewController and I'm noticing that I've done something to where the
I have an NSTimer that fires off every second, and on that second I
Can anyone please identify is there any possible memory leaks in following code. I

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.