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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:17:06+00:00 2026-06-03T03:17:06+00:00

I load a static property list from my main bundle. Simple enough. However the

  • 0

I load a static property list from my main bundle. Simple enough. However the property list is not deallocated after I set it to nil. Why is this? The allocated memory is easy to monitor, as the property list is huge.

NSPropertyListFormat format = NSPropertyListBinaryFormat_v1_0; 
NSError *error = nil; 
NSArray *myArray = [NSPropertyListSerialization propertyListWithData:[NSData dataWithContentsOfFile:bundleFilePath] 
                                                                          options:NSPropertyListImmutable
                                                                           format:&format
                                                                            error:&error];

myArray = nil; 
// Still takes up allocated space (as seen in memory monitor via instruments).

With autorelease pool:

- (void)someMethodCalledOnTheMainThread
{ 
    @autoreleasePool {
        NSString *bundleFilePath = @"..."; 
        NSPropertyListFormat format = NSPropertyListBinaryFormat_v1_0; 
        NSError *error = nil; 
        NSArray *myArray = [NSPropertyListSerialization propertyListWithData:[NSData dataWithContentsOfFile:bundleFilePath] 
                                                                          options:NSPropertyListImmutable
                                                                           format:&format
                                                                            error:&error];
    }

}
  • 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-06-03T03:17:07+00:00Added an answer on June 3, 2026 at 3:17 am

    The array has been autoreleased. According to the memory management guidelines, the propertyListWith... method will return an autoreleased object, which means there is a reference to the object which will be released at some point in the future. Your code is basically equivalent to this (without ARC):

    NSArray *myArray = [[NSPropertyListSerialization propertyListWith/*stuff*/] retain];
    // 1 reference + 1 autoreleased reference
    [myArray release]; myArray = nil;
    // 1 autoreleased reference
    

    Since you didn’t drain the autorelease pool containing the array, there is still a reference to it. It will be deallocated at some point in the future, most likely when the current run loop ends or thread exits. If you want to force the array to be released sooner, you can create your own autorelease pool.

    @autoreleasepool {
        NSArray *myArray = [[NSPropertyListSerialization propertyListWith/*stuff*/] retain];
        // 1 reference + 1 autoreleased reference
        [myArray release]; myArray = nil;
        // 1 autoreleased reference
    } // no references. The array is deallocated
    

    Now, the array is released at a known time. Note that any other autoreleased objects created within the pool’s scope will also be released, which could cause problems if you don’t plan for it. This gives you more explicit control over when the array is deallocated, but most likely will not create a noticeable difference unless you are creating this property list within a loop, since the run loop would soon drain its autorelease pool after you return.

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

Sidebar

Related Questions

I want to make a static class that would load some settings from XML
ViewA load some data from Coredata, then push to the next viewB . In
i load a class using Class.forName(klassname,false,loader) After this i create an instance using klass.newInstance();
I load a page with jquery like this: $('#container').load('books/book1/inleiding.php'); However, the images are in,
I load a form and dynamically populate a select via AJAX from a PHP
I try to load a property-file that is here <project>/resource/text/translation_en.properties With the following code
I would like to know how to add a property from one of my
My GWT app, using UiBinder, won't load in Internet Explorer. However, it loads just
I'm trying to load a list of Evaluations in a class named Contributor but
I've got a couple dictionaries in a property list, that make up a menu

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.