Re: questions on memory issues
Re: questions on memory issues
- Subject: Re: questions on memory issues
- From: Matt Neuburg <email@hidden>
- Date: Tue, 10 Nov 2009 18:40:43 -0800
- Thread-topic: questions on memory issues
On Tue, 10 Nov 2009 13:41:37 -0800, John Michael Zorko <email@hidden>
said:
>
>Hello, all ...
>
>Firstly, I very much appreciate the help i've received here -- thank
>you very much :-)
>
>I've a debugging question. I've an issue that manifests as what
>appears to be a dangling pointer. I've a view that is loaded, and all
>is fine. This is OS 2.2.1. My understanding is that under OS 2.x, the
>view controller only releases it's view when the view controller is
>released. However, if I put a breakpoint on my view controller's -
>loadView method, it's called again sometime later (and it's view
>property is now something completely different, pointing to an
>NSArray, NSOperation or something else), without the view controller's
>-dealloc method being called beforehand. I would think that if the
>view controller had to be released, say because of a memory warning,
>that its' -dealloc method would be called. I don't know why it's not ...
The view controller's dealloc tells you if the view controller is released,
but it doesn't tell you anything about whether the *view* is released. So
your breakpoint is in the wrong place. What you want is to put a breakpoint
(or an NSLog) in the *view's* dealloc, so you can understand when that's
happening. For example, suppose your view controller's view @property is
marked "(assign)" - or nothing at all - instead of "(retain)". I would
imagine that in that case the view, whether loaded from the nib or created
in some other way, will promptly vanish as soon as it's created, kapoof
(that's the actual noise it makes, though most people can't hear it),
because nothing is retaining it. The next time the view is referred to, an
attempt will be made to load it again, but as you've discovered, we're now
pointing at garbage. Also, note that if you're loading your view from a nib
(via initWithNibName:), you're not supposed to override loadView at all. m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden