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: Clark Mueller <email@hidden>
- Date: Fri, 23 Aug 2002 11:13:35 -0600
I think the short version is that I need to read up on memory
management. :-) I do think I will rewrite for NSMutableArray though.
None of this would be a problem if I could find a way to make an
NSDirectoryEnumerator return full path names, and not file names
representing the contents. Any ideas there, anyone?
Thanks,
Clark
On Friday, August 23, 2002, at 10:56 AM, Lance Bland wrote:
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.
Clark Mueller
email@hidden
---
http://www.finikin.com/
---
Computer programmers don't byte, they nibble a bit.
_______________________________________________
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.