Re: EXC_BAD_ACCESS in an strange place
Re: EXC_BAD_ACCESS in an strange place
- Subject: Re: EXC_BAD_ACCESS in an strange place
- From: Lance Bland <email@hidden>
- Date: Fri, 23 Aug 2002 12:56:06 -0400
On Friday, August 23, 2002, at 12:33 PM, Clark Mueller wrote:
>
> filesArray = [filesArray arrayByAddingObject:[folder
>
> stringByAppendingPathComponent:file]];
ouch! man that line really hurts.
Even though you init filesArray with a retain count of one, you then
reassign it to an instance with an autorelease. You can probably design
a more efficient version using NSMutableArray.
>
What was happening? Why wasn't my check for filesArray == nil catching
>
this?
Because the *object* with symbol filesArray was released, not the
reference to it, so filesArray still points to a region of memory that
was deallocated. The autorelease pool will not clean up invalid
references to memory because nothing maintains a reverse key to those
references and it will not scan your image to find them.
... you should probably name "filesArray" to "fileArray" since the "s"
(plural) is redundant once you suffix it with "Array".
-lance
------------------------------------
Lance Bland
mailto:email@hidden
web charts at
http://www.vvi.com/products/chart
_______________________________________________
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.