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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T05:39:05+00:00 2026-05-21T05:39:05+00:00

I just stumbled about an issue in my app: I tested the didReceiveMemoryWarning calls

  • 0

I just stumbled about an issue in my app: I tested the didReceiveMemoryWarning calls to an UIViewController including the follow-up calls for viewDidUnload.

This used to work fine in older versions of my app, but was not working now within iPhone Simulator:
didReceiveMemoryWarning was just not called any more.

This was caused by calling [NSNotificationCenter defaultCenter] removeObserver:self] in viewWillDisappear (self being the UIViewController) to unregister for some lifecycle notifications I did add in viewDidAppear.

That global removeObserver: call did not only remove my added notifications, but apparently also the system’s UIApplicationDidReceiveMemoryWarningNotification notification caused the UIViewController’s didReceiveMemoryWarning being called.

Is this behaviour by design? I could not find a reference/document which was pointing out, that calling removeObserver: within a UIViewController breaks the standard memoryWarning handling.

  • 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-21T05:39:06+00:00Added an answer on May 21, 2026 at 5:39 am

    Yes, this is by design.

    This behavior doesn’t surprise me at all. The implementation of UIViewController is opaque so there is no way to know for sure that it is registering instances for UIApplicationDidReceiveMemoryWarningNotification with the didReceiveMemoryWarning action but that would certainly make sense.

    As a general rule, it’s bad practice to use [[NSNotificationCenter defaultCenter] removeObserver:self] anywhere but in dealloc. This is because, as you’ve discovered, there can be unpredictable side effects in superclass implementations. It’s more predictable and easier to debug/maintain your code if you follow the convention of only unregistering for the specific notifications you registered for.

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

Sidebar

Related Questions

I just read about maintaining state of my android app and stumbled upon onRetainNonConfigurationInstance.
I just stumbled upon this blog post about cache algorithms. The author shows two
I just read this question and stumbled upon the following quote: Scala treats ==
just when I thought I understood something about type conversion in JavaScript, I stumbled
I just found out about html agility pack and I tried it, but stumbled
I recently stumbled upon this page . And I was particularly interested about the
I just stumbled across this bug in some legacy code: class MyAPIHandler { private:
I just stumbled about some situation that seems weird to me. I might very
Just stumbled upon propertyGrid and its awesome! However, i have one task that i
Ive just stumbled across property on a text box and it sounds the ideal

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.