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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:07:59+00:00 2026-05-30T11:07:59+00:00

I am in the process of optimizing my app and making sure memory management

  • 0

I am in the process of optimizing my app and making sure memory management is properly implemented. As I found the didUnload / dealloc / willAppear not reliable for implementing my memory cleanup, I decided to implement my own method so I can have full control of this memory management.

Definition of my arrays in the header file

@property (retain) NSMutableArray *selectedCardIDs;
@property (retain) NSMutableArray *selectedRowArray;
@property (retain) NSMutableArray *cardArray;
@property (retain) NSMutableArray *cardIDArray;

Here the release method:

- (void) willReleaseObjects {
[self.aCopyOfCardIDArray release];
[self.listOfItems release];
[self.aCopyListOfItems release];
[self.selectedCardIDs release];
[self.selectedRowArray release];
[self.cardArray release];
[self.cardIDArray release];

}

The arrays can get very large (> 1’000 entry each), why a release of those arrays is essential after the view is unloaded. I explicitly call this function in the IBAction method, such as:

- (IBAction) stopDictionary:(UIBarButtonItem *) sender {
[self closeDatabase];
[self willReleaseObjects];
[self dismissModalViewControllerAnimated:YES];

}

I debugged the code and it is actually executing each release, however when I diagnose the memory allocation with Instruments, it seems to free up only partial memory, actually almost nothing why the memory consumption of course is increasing every time I load this view again, which is no good at all.
Any idea, why my memory is not released here? Thanks.

  • 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-30T11:08:01+00:00Added an answer on May 30, 2026 at 11:08 am

    Don’t call release on a property as you risk something very bad happening in case you have any properties declared as assign or copy. You could potentially release a returned instance which is already autoreleased.

    Instead either release the instance variable behind it or set the property to nil. Either way you will achieve the correct result. In case you have any Key/Value observers on your properties the best way is to set the properties to nil which will automatically propagate the values to any observers:

    - (void) willReleaseObjects {
      self.aCopyOfCardIDArray = nil;
      self.listOfItems = nil;
      ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are developing a Winforms application and in the process of optimizing the start-up
Process.Start(IExplore.exe); Does this always work, on every machine ? If not, how to do
Every process can use heap memory to store and share data within the process.
I am in the process of optimizing magento store, and I've run across a
I am currently in the process of optimizing a numerical analysis code. Within the
I'm in the process of optimizing an import of ~10TB of Data into a
I'm in the process of optimizing a high traffic site. The site I am
I am in the process of optimizing a contact importer tool that process a
I'm in the process of optimizing my SQL queries on my heroku server so
My process is as follows: User logs into web app and this drops an

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.