| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
On Jul 29, 2006, at 6:43 PM, stephen joseph butler wrote:
Every 5 seconds you're creating a helper thread that will perform a 12 minute directory scan. See where I'm going with this?
There's more to it than the snippet shows but I get the drift.
Yes. You're spawning multiple threads, all of which are trying to access the same mutable array without any sort of locking. This is will most certainly cause random memory corruption.
You have a couple options:
1) allocate an NSLock along with the NSMutableArray and synchronize access to your collection. 2) allocate a temporary NSMutableArray inside scanDirectoriesInThread: and only after you're done assign it to holdingBin. However, you'll want to release whatever's there, so you need a lock for holdingBin to make sure you have exclusive access. That is...
[holdingBin lock]; [holdingBin release]; holdingBin = nil; holdingBin = tempArray; [holdingBin unlock];
Thanks Joseph I'll look into locks
Ken
_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/email@hidden
| References: | |
| >malloc/free problems within a thread (From: Ken Tozier <email@hidden>) | |
| >Re: malloc/free problems within a thread (From: Ken Tozier <email@hidden>) | |
| >Re: malloc/free problems within a thread (From: Ken Tozier <email@hidden>) | |
| >Re: malloc/free problems within a thread (From: "stephen joseph butler" <email@hidden>) |
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.