0

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

I must be doing something wrong here. Compiler is set to Apple LLVM Compiler 3.0 and Objective-C Automatic Reference Counting is set to YES. I also have 3rd Party Software included that requires ARC to be active.

So my basic problem is that my properties don't get released. I have the following header:

@interface ArchiveController : UIViewController <CloseSubviewDelegate> {
  NSArray *journals;
  NSMutableArray *archiveViews;
}

@property (nonatomic, strong) NSArray *journals;
@property (nonatomic, strong) NSMutableArray *archiveViews;

....

@end

I synthesized those and initialize the archiveViews array like this:

self.archiveViews = [NSMutableArray array];

later I add objects to it, everything works fine; same for the journals array.

I added a dealloc method to check that the ArchiveController gets released:

-(void)dealloc
{
   DLog(@"dealloc archive controller");
}

which works, but the arrays are never released; Why? If I change the dealloc method to this:

-(void)dealloc
{
  DLog(@"dealloc archive controller");
  self.archiveViews = nil;
}

everything works fine, but thats not the way it should be, right? I'm a 100 % certain that the array and its objects aren't referenced anywhere else.

And isn't the Preprocessor supposed to handle the insertion of all the retains/releases/deallocs? when I let Xcode generate preprocessed output, nothing seems changed!

Community
  • 1
  • 1
cboe
  • 469
  • 1
  • 9
  • 25
  • How do you know array isn't released? – Aleksejs Mjaliks Feb 29 '12 at 21:09
  • It's possible to turn ARC off on a file-by-file basis, by adding per-file compilation flags in the build phase area. Presumably that's not the case here, but it may be worth double-checking. The flag that would turn this off is `-fno-objc-arc`. – Lily Ballard Feb 29 '12 at 21:22
  • because the objects inside the array are never released. Thx Kevin for noticing, but that's not the case. – cboe Mar 15 '12 at 13:04

1 Answers1

0

I suspect a circular dependency.

Instruments can help you locate them at times.

justin
  • 104,054
  • 14
  • 179
  • 226
  • If there was a retain cycle here, then his `-dealloc` wouldn't be called at all, which means the `self.archiveViews = nil;` would never be run. – Lily Ballard Feb 29 '12 at 21:22