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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:29:15+00:00 2026-05-28T02:29:15+00:00

I’m writing an app (in iOS 5 using ARC!) that presents several hundred objects

  • 0

I’m writing an app (in iOS 5 using ARC!) that presents several hundred objects within a custom UIViewController I’ve written that a user may scroll through and select, each of which is presented as a thumbnail image that the user may touch.

Each of these objects has associated with it a special UIViewController subclass that handles the custom presentation of the information associated with that object. For example, it might be an image that can be zoomed and panned, or simply some text that needs to be formatted.

Now, each of my image objects has a large image associated with it. Using the Instruments app to profile my code and running Activity Monitor, I see that these take up roughly 5-10MB each when the custom UIViewController subclass loads and the image is displayed. This is fine for a few images, but eventually my app takes up too much memory and crashes.

I have written in my subclass’s -viewDidUnload method apparently all of the things necessary to tell ARC to free up this memory, but no memory is being freed until warnings are issued, which typically occurs when the app is about to crash. A couple of times, I’ve noticed that if I get close enough to the threshold but don’t go over it, the UIViewController subclasses that I’ve previously viewed are eventually flushed from memory, although the -viewDidUnload method is not apparently called (rather, the -didReceiveMemoryWarning message is sent to my custom UIViewControllers). However, most often, my app crashes as it runs out of memory.

So my core question is, should I assume that an object will be disposed of by ARC as soon as possible, or does it always wait until space becomes tight? The behavior I want is for the custom view controller and its data to be flushed right away, so that memory never becomes an issue.

I do not believe there are any strong references from objects to my custom view controllers, and I instantiate them in my primary view controller using this code:

[self presentViewController:[cObj grabModalViewController]
                   animated:YES completion:nil];

where cObj is a custom class with the object’s information. grabModalViewController simply instantiates an object of the correct type and returns the pointer, so presumably the local reference to the object should be trashed as soon as the method completes.

As a result, I would expect that, when I later call

[self dismissModalViewControllerAnimated:YES];

the custom view controller that was only pointed to be the primary view controller via presentedViewController should be flushed from memory, but this does not happen.

Could this be because I have strong references within my custom view controller object?

Essentially what I’m trying to accomplish is to avoid as many memory warnings as possible by managing things better up front, but perhaps this is not the right attitude.

I’d appreciate any suggestions and I’m happy to post any and all code that would be helpful.

  • 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-28T02:29:16+00:00Added an answer on May 28, 2026 at 2:29 am

    So my core question is, should I assume that an object will be
    disposed of by ARC as soon as possible, or does it always wait until
    space becomes tight?

    ARC is a compile time technology. It knows nothing about your runtime memory heap. Hence, it cannot wait to release items until space becomes tight. A specific answer to your question is that ARC will release anything as soon as you no longer need it.

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I am writing an app with both english and french support. The app requests
I am using Paperclip to handle profile photo uploads in my app. They upload
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.