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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:34:35+00:00 2026-05-15T17:34:35+00:00

When we need to release an object,where to do it, either at the dealloc

  • 0

When we need to release an object,where to do it, either at the dealloc method or in the ViewDidUnload for a viewController? which would be better?

I think that viewDidUnload would do better, because once the view controller is unloaded the objects would be released. And in the dealloc case, from the documentation

When an application terminates,
objects may not be sent a dealloc
message. Because the process’s memory
is automatically cleared on exit, it
is more efficient simply to allow the
operating system to clean up resources
than to invoke all the memory
management methods.

the objects may not be sent a dealloc message upon the Application quitting.

So I find it would be better if objects got released earlier, than postponing their release thereby reducing the memory footprint the Application takes.

If my understanding is wrong, please correct me.

Thanks and Regards,
Krishnan

  • 1 1 Answer
  • 1 View
  • 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-15T17:34:36+00:00Added an answer on May 15, 2026 at 5:34 pm

    Yes, your understanding is wrong.

    First, it doesn’t matter what happens when the application quits because the OS will free all the memory that your app allocated anyway. Not calling dealloc on app termination is just Apple’s way to speed this up.

    Second, it is not the view controller that is unloaded when viewDidUnload is called but only its view. The view controller stays alive until it is deallocated.

    In viewDidUnload, you have to release those objects that are part of the view and everything that can and will be recreated in viewDidLoad (because viewDidLoad will be called again when the view controller need to recreate its view). This includes all your outlets. You also have to set these variables to nil to avoid overreleasing them.

    Because in dealloc, you should release all objects your view controller retains, including those you included in viewDidUnload.

    Have a look at any of Apple’s sample code to see how Apple does this.

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

Sidebar

Ask A Question

Stats

  • Questions 492k
  • Answers 492k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I'm not sure what kind of adapter you are using,… May 16, 2026 at 10:24 am
  • Editorial Team
    Editorial Team added an answer static List<T> RemoveDuplicates<T>(List<T> inputList) { Dictionary<T, int> uniqueStore = new… May 16, 2026 at 10:24 am
  • Editorial Team
    Editorial Team added an answer Network security with OpenSSL OpenSSL: Open Source, Transport Layer Security,… May 16, 2026 at 10:24 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

If you set a property to nil in viewDidUnload do you need to release
I have a small WinForms app that utilizes a BackgroundWorker object to perform a
I'm testing my project installation script on CentOS5.5. My project need Date::Manip module which
I'm having a recurring problem in Objective-C. I'm either releasing things too many time,
I have a need to run some automation tasks in a web browser control
I need the the .ASPX file to behave differently based on a conditional compilation
I need to be able to get the weekday from nsdate, i have the
I'm using rvm (Ruby Version Manager) and running Rails 3 RC. I need to
I am upgrading my Rails plugin to be an engine that works with the
I am trying to understand what is happening in the getter below, this is

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.