Re: Saving Data and Type 10/11 Errors
Re: Saving Data and Type 10/11 Errors
- Subject: Re: Saving Data and Type 10/11 Errors
- From: email@hidden
- Date: Wed, 08 May 2002 10:59:30 -0700
Peter Thorson wrote:
|Also, I frequently get type 10 and 11, (SIGBUS) and (SIGSEGV), errors.
|What exactly are they and what is the best way of avoiding problems
|related to them?
Basically, they're different ways of the system telling you you're trying to use something as a memory address which is actually garbage. Most often, it means that some pointer variable ("Xxxx *" or "id") hasn't been initialized. It can also mean that you're using a pointer to an object that's already been released.
Some fixes (covering the common causes):
* Make sure your "init:" routine initializes every instance variable
* Make sure your "init:" routine is being called. (I get bit by this one every so often.) Objects loaded from nib files are particular culprits here. They have to be initialized in the "awakeFromNib" method instead, because "init:" (in any variation) isn't ever called.
* Make sure local variables are initialized properly.
(The pattern should be pretty obvious by now.)
* If you release an object, set the variable pointing to the object to nil/NULL (unless the variable is about to go away)
* Make sure you retain any object that you don't want released by the autorelease mechanism. In particular, objects created by any method which doesn't include "alloc" or "copy" in its name are slated for autorelease unless you retain them.
Glen Fisher
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.