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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T20:35:48+00:00 2026-05-14T20:35:48+00:00

Clarification question as a follow up to: What exactly must I do in viewDidUnload?

  • 0

Clarification question as a follow up to:

What exactly must I do in viewDidUnload?
When should I release objects in -(void)viewDidUnload rather than in -dealloc?

So let’s say there’s a low memory error, and the view is hidden, and viewDidUnload is called. We do the release and nil dance. Later the entire view stack is not needed, so dealloc is called. Since I already have the release and nil stuff in viewDidUnload, I don’t have it in dealloc. Perfect.

But if there’s no low memory error, viewDidUnload is never called. dealloc is called and since I don’t have the release and nil stuff, there’s a memory leak.

In other words, will dealloc ever be called without viewDidUnload being called first?

And the practical follow up to that is, if I alloc and set something in viewDidLoad, and I release it and set to nil in viewDidUnload, do I leave it out of dealloc, or do I do a defensive nil check in dealloc and release/nil it if it’s not nil?

  • 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-14T20:35:48+00:00Added an answer on May 14, 2026 at 8:35 pm

    Release it in both. You don’t need to check for nil. Release on a nil does nothing.

    However in viewDidUnload don’t release ivars that you can’t easily recreate in viewDidLoad, in case the view becomes loaded again.

    Normally (no memory warnings) viewDidUnload doesn’t gets called, only dealloc is called.

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

Sidebar

Related Questions

Follow up question to this: Linq Combine Left Join Data Say I have the
And which way is better? Let me know if the question needs clarification.
This is a clarification question I've got from a Java EE 5 migration. I'm
Clarification/summary for the question -- we're looking for: a hosted bug tracking system, that
I'm seeking further clarification after seeing What is responsible for releasing NSWindowController objects? I'm
This is a follow-up question to a different question I asked not too long
i need some clarification please: the process is essentially as follow: client fills out
This is a clarification question: I'm studying for MCTS 70-515 and in my training
I have a question about clarification of my homework. http://www.cs.bilkent.edu.tr/~gunduz/teaching/cs201/cs201_homework3.pdf To see the handout
EDIT : UPDATING MY QUESTION FOR MORE CLARIFICATION ========================================================== I use MeioUpload to upload

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.