Re: Main window disappears. Sometimes.
Re: Main window disappears. Sometimes.
- Subject: Re: Main window disappears. Sometimes.
- From: Paul Sargent <email@hidden>
- Date: Mon, 2 Jun 2008 19:55:31 +0100
On 2 Jun 2008, at 12:16, Francis Perea wrote:
Hi Paul.
I've disabled GC as Michael and you propose and the application it's
working right now.
I've had to "retain" both properties of the model class (generator)
and the instance of that class in the controller class
(generatorcontroller).
There's a few simple rules that specify when you have to retain
something, and when you don't. The document Graham gave you goes
through them.
I don't want to repeat them here because I'd probably get it slightly
wrong and people love to argue over the fine detail. We found that out
in another thread recently.
I've also had to implement both dealloc method of both classes so
that all retained objects get released.
Is that right?
Yes, that's exactly the reason for dealloc.
And a final question, I would like to know if my application frees
up all memory it uses after stopping and it has no memory leaks; I
think Instruments is the utility Apple provides for that matter,
isn't it?
An application will automatically free everything when it quits.
If you want a way of seeing if you've released everything you
allocated, then it's worth looking back in the archive a couple of
weeks, as there was a thread talking about how to do it. I think the
conclusion was "put a sleep statement before the app quits". That way
you have some time to see the final state.
In that case I should read Instruments help so that I know how to
get that information, cos I've tried to use it but it doesn't seem
very friendly to me :-(
Instruments is one tool that can do it. Also there's the 'leaks'
command line tool, and ObjectAlloc (which appears to be an Instruments
template now).
Don't worry too much about getting rid of all memory leaks while
you're learning. There's lot's of stuff to learn, and as you get more
experience you'll start to see the patterns. If you get problems with
over releasing something (which will often cause you to crash), search
for NSZombiesEnabled in the docs.
Have fun.
_______________________________________________
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