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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:52:47+00:00 2026-05-30T06:52:47+00:00

In a view controller I have a UIImageView as a subview. On willRotateToInterfaceOrientation, i

  • 0

In a view controller I have a UIImageView as a subview. On willRotateToInterfaceOrientation, i replace it with a different UIImageView. If both are in memory at the same time, it sometimes jettison crashes because the images are very big. So i want to make sure I completely dealloc the first one before making the new one. When i call removeFromSuperview on it, I think it is basically autoreleasing at some point later, but I need it to be dealloced immediately.

So it seems i need my own autorelease pool when the UIImageView is created, and then drain it when willRotateToInterfaceOrientation gets called, after the removeFromSuperview call. But the documentation says:

An autorelease pool should always be drained in the same context (such
as the invocation of a method or function, or the body of a loop) in
which it was created. Autorelease pools are used “inline.” There
should typically be no reason why you should make an autorelease pool
an instance variable of an object.

So what is the “right” way to do this?

  • 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-30T06:52:49+00:00Added an answer on May 30, 2026 at 6:52 am

    The best thing to do is optimize your images. It is imperative that an autorelease pool is allocated and drained within the same context. First thing you should is try to reduce the size of the image. If they are png’s try pngcrush. If the images are still to large consider using mmap to load portions of the image at a time.

    Performance Tuning

    Impose size limits on resources.
    Avoid loading a large resource file when a smaller one will do. Instead of using a high-resolution
    image, use one that is appropriately sized for iOS-based devices. If
    you must use large resource files, find ways to load only the portion
    of the file that you need at any given time. For example, rather than
    load the entire file into memory, use the mmap and munmap functions to
    map portions of the file into and out of memory. For more information
    about mapping files into memory, see File-System Performance
    Guidelines.

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

Sidebar

Related Questions

I have a View Controller, and a UIImageView as a subview. That UIImageView also
I have a UIImageView property in my view controller set to assign. Every time
I have one view controller in which I have added UIScrollView & UIImageView programatically.
The Problem: I have two View Controllers loaded into a root View Controller. Both
I have a view controller and a view. I then have a UIImageView created
I have view controller, into the view i have put a table view, and
Example: I have a view controller and get rid of it. But there's still
I have a Table View Controller with cells. I want to update the text
I have two view controller classes in my application delegate. I can change from
I have a view controller and I am intercepting the touches on links within

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.