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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:08:00+00:00 2026-05-28T13:08:00+00:00

Possible Duplicate: Why is object not dealloc'ed when using ARC + NSZombieEnabled I’ve got

  • 0

Possible Duplicate:
Why is object not dealloc'ed when using ARC + NSZombieEnabled

I’ve got a very strange issue I’m seeing at the moment in a project. Put simply I have ViewA which owns ViewB (strong property). ViewA creates its ViewB in its initialiser. Both objects are subclasses of UIView.

I have overridden dealloc in both and put a log line and a break point to see if they get hit. It seems that ViewA‘s dealloc is being hit but not ViewB‘s. However if I put in a self.viewB = nil in the dealloc of ViewA then it is hit.

So basically it’s something like this:

@interface ViewA : UIView
@property (nonatomic, strong) ViewB *viewB;
@end

@implementation ViewA

- (id)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.viewB = [[ViewB alloc] initWithFrame:self.bounds];
        [self addSubview:self.viewB];
    }
    return self;
}

- (void)dealloc {
    //self.viewB = nil; ///< Toggling this commented/uncommented changes if ViewB's dealloc gets called.
    NSLog(@"ViewA dealloc");
}

@end

What I can’t understand is why nil-ing viewB out makes a difference. If something else is holding onto viewB then it should make absolutely no difference if I nil it out or not here. And it shouldn’t make a difference to the number of releases that ARC adds in either.

I can’t seem to reproduce it in a minimal test case as yet, but I’m working on it. And I can’t post the actual code I’m seeing this in unfortunately. I don’t see that being an issue though because it’s more the point that nil-ing it out shouldn’t make a difference that I am confused by.

Can anyone see anything I am overlooking or give advice about where to look for debugging this problem?

Update:

I’ve found the problem. It appears that it’s only a problem when NSZombieEnabled is set to YES. Well that is entirely mad and has to be a bug surely. Zombies should not affect how this works as far as I know. The objects should still go through the dealloc method. And what’s more, it’s just mad that it works if I nil out viewB in ViewA‘s dealloc.

  • 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-28T13:08:01+00:00Added an answer on May 28, 2026 at 1:08 pm

    I’ve found that this appears to be a bug in the iOS implementation of zombies. Consider the following code:

    #import <Foundation/Foundation.h>
    
    @interface ClassB : NSObject
    @end
    
    @implementation ClassB
    - (id)init {
        if ((self = [super init])) {
        }
        return self;
    }
    - (void)dealloc {
        NSLog(@"ClassB dealloc");
    }
    @end
    
    @interface ClassA : NSObject
    @property (nonatomic, strong) ClassB *b;
    @end
    
    @implementation ClassA
    @synthesize b;
    - (id)init {
        if ((self = [super init])) {
            b = [[ClassB alloc] init];
        }
        return self;
    }
    - (void)dealloc {
        NSLog(@"ClassA dealloc");
    }
    @end
    
    int main() {
        ClassA *a = [[ClassA alloc] init];
        return 0;
    }
    

    That should output:

    ClassA dealloc
    ClassB dealloc
    

    But with NSZombieEnabled set to YES, it outputs:

    ClassA dealloc
    

    As far as I can tell, this is a bug. It seems to only happen with iOS (both simulator and device) and does not happen when built and run for Mac OS X. I’ve filed a radar with Apple.

    Edit: It turns out this has already been answered here – Why is object not dealloc'ed when using ARC + NSZombieEnabled . Managed to find it after I found out what the real problem was. It’s nothing to do with ARC by the way.

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

Sidebar

Related Questions

Possible Duplicate: What are the reasons why Map.get(Object key) is not (fully) generic According
Possible Duplicate: Submit a form using jQuery $('#form') Supposed the jQuery Object of the
Possible Duplicate: Difference between using var and not using var in JavaScript For the
Possible Duplicate: Rails primary key and object id Very quick question. My server is
Possible Duplicate: What are the reasons why Map.get(Object key) is not (fully) generic From
Possible Duplicate: What are the reasons why Map.get(Object key) is not (fully) generic This
Possible Duplicate: What is object serialization? I've made a small RSS Reader app using
Possible Duplicate: Calling closure assigned to object property directly Why this is not possible
Possible Duplicate: What are the reasons why Map.get(Object key) is not (fully) generic This
Possible Duplicate: Scala equivalent of Java java.lang.Class<T> Object Hi all, I can not call

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.