• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSLock and AutoreleasePool question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSLock and AutoreleasePool question


  • Subject: NSLock and AutoreleasePool question
  • From: Development <email@hidden>
  • Date: Tue, 15 Jan 2008 23:05:10 -0700

Ok, I read up on the NSLock and becoming thread safe. My application is designed to download items and it does this in a loop. Each item may have several parts so 1 file may consist of a dozen ore more requests to the server. It also requires I use a number of things that my reading has told me are not thread safe. Particularly, NSMutableData and NSMutableString. Now, if I understand what I was reading and well, I'm not sure I did... When I alter mutable data I should put a lock around it correct?

[aLock lock];

	*alter mutableData*
[aLock unlock];

Is this the correct idea?

Also in each loop I have an NSAutoreleasePool because if I don't this app will chew all the memory available in seconds. As well as the auto release pool around the method that is called with detachNewThreadSelector
This is the problem. I have to have the pools to reclaim memory don't I? But I keep having crashes and the line I'm crashing at is always a [autoReleasePool release] call. It may be the one inside the loop, or the function that was originally detached, but it's always one or the other. This means I am either not using locks correctly, or the autorelease pool or both. I have tried locking the thread around the autoreleasepool release but that did not help. I have also tried the @synchronize() directive but I may not be using it correctly. I've tried synchronizing both the various bits of mutable data and the pool itself before releasing it... Can some one help shed a little light on this? I can provide code segments if you need to see them but they are too large to include here.


Thanks.
_______________________________________________

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


  • Follow-Ups:
    • Re: NSLock and AutoreleasePool question
      • From: "stephen joseph butler" <email@hidden>
  • Prev by Date: Re: CoreData NSTreeController Binding Relationship Problem
  • Next by Date: Re: Handle Dock menu open/close events
  • Previous by thread: Re: Handle Dock menu open/close events
  • Next by thread: Re: NSLock and AutoreleasePool question
  • Index(es):
    • Date
    • Thread