• 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
Re: looking for a memory problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: looking for a memory problem


  • Subject: Re: looking for a memory problem
  • From: Mike Abdullah <email@hidden>
  • Date: Wed, 18 Jul 2012 00:09:37 +0100

On 17 Jul 2012, at 18:10, Martin Hewitson wrote:

> So my potential solution for this is:
>
> NSSpellChecker *checker = [NSSpellChecker sharedSpellChecker];
> __block NSRange range = NSMakeRange(0, 0);
> while (range.location < [aString length]) {
>
>    dispatch_sync(dispatch_get_main_queue(), ^{
>      range = [checker checkSpellingOfString:aString startingAt:range.location];
>    });
>
>   // update range
> }
>
> Where this piece of code will run on multiple threads.
>
> Does this look like a reasonable approach to ensuring thread safety?

Two potential problems:

- If the main thread is waiting on your thread/queue to do its work, then you’ve got a deadlock. Hopefully your code never does that

- If you run this code on the main thread, it’ll deadlock also. You might find something like KSThreadProxy a neater solution to this problem.


_______________________________________________

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


References: 
 >looking for a memory problem (From: Martin Hewitson <email@hidden>)
 >Re: looking for a memory problem (From: Charlie Dickman <email@hidden>)
 >Re: looking for a memory problem (From: Martin Hewitson <email@hidden>)
 >Re: looking for a memory problem (From: Martin Hewitson <email@hidden>)
 >Re: looking for a memory problem (From: Fritz Anderson <email@hidden>)
 >Re: looking for a memory problem (From: Martin Hewitson <email@hidden>)
 >Re: looking for a memory problem (From: Martin Hewitson <email@hidden>)

  • Prev by Date: Re: Help with strange NSInvalidArgumentException
  • Next by Date: Re: How can I convince an NSBigMutableString to become a mere NSAttributedString ?
  • Previous by thread: Re: looking for a memory problem
  • Next by thread: Re: looking for a memory problem
  • Index(es):
    • Date
    • Thread