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

  • Home
  • SEARCH
  • 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 7536623
In Process

The Archive Base Latest Questions

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

I need to load some data in my UIViewController to show a UIPickerView widget

  • 0

I need to load some data in my UIViewController to show a UIPickerView widget in an iPhone modal view.

I did some research and found this answer in SO. I proceeded to implement my data reading code in initWithNibName:bundle: and data unloading in dealloc. However, Instruments kept telling me there was a memory leak when repeatedly showing the modal view, and during debugging I noticed initWithNibName:bundle: was called each time the view was shown, but dealloc was never called under normal execution (although it’s triggered by a low-memory condition as per Apple’s UIViewController Class Reference document, and the same applies to viewDidUnload).

I ended up loading data in the viewDidLoad: method and I released it in viewDidDisappear:, the widget shows the data and there are no leaks. However, I’d like to know if there are any good practices in regards to this, because on one comment in Apple’s documentation mentions this:

You should not use this method (i.e. viewDidUnload) to release user data or any other information that cannot be easily recreated.

I assumed the right way was load data in viewDidLoad and releasing all references to it in viewDidUnload, but in practice the latter method is not called unless a low-memory condition arises, and consequently each time the view is displayed, the data is loaded again and the reference to the old data is lost, causing the memory leak.

Thanks for your comments.

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

    Something bad is happening if viewDidLoad is getting called every time your view is shown. viewDidAppear should get called, but viewDidLoad should only be called the first time the view is needed and if the view is needed and viewDidUnload got called.

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

Sidebar

Related Questions

I have some data from DB then I need to load. Something like this
I have a c++ application. I need to load some config data from file.
I'm creating a custom ViewController. This VC needs to load some data that is
i need a jquery plugin to show full description of some data as a
I am new to Sencha Touch framework. I need to load some data from
Need to store some data in window.load and retrieve in document.ready : <script> $(window).load(function()
I need to load some resource from my DLL (i need to load them
To complete some testing I need to load the 64 bit version of an
Two Delphi programs need to load foo.dll, which contains some code that injects a
I need to Pass some data to a text file and save that text

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.