• 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: NSSpellChecker crashes after 64k words
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSSpellChecker crashes after 64k words


  • Subject: Re: NSSpellChecker crashes after 64k words
  • From: "Louis C. Sacha" <email@hidden>
  • Date: Tue, 12 Apr 2005 03:07:17 -0700

Hello...


I don't think your problem is specifically related to NSSpellchecker, it's probably just that too many autoreleased objects are being created within your loop.


The following example code crashes after a number of iterations similar to what you indicated (note that the word "mage" is apparently not a real word in American English, but it doesn't really make any difference whether the word is misspelled or not):

	NSSpellChecker *checker = [NSSpellChecker sharedSpellChecker];
	NSString *testString = @"mage";
	NSRange found;

unsigned i, j;
for (i=0; i<100; i++)
{
for (j=0; j<1024; j++)
{
found = [checker checkSpellingOfString:testString startingAt:0];
}


		NSLog(@"count %i",(i*1024 + j));
	}

If you add a couple lines to create and destroy a temporary autorelease pool within the loop doing all of the work, it should fix the problem. My choice to use 1024 iterations per pool was arbitrary, and you'd probably want to experiment a bit to figure out how often to do it to keep your app's memory footprint in check.

	NSSpellChecker *checker = [NSSpellChecker sharedSpellChecker];
	NSString *testString = @"mage";
	NSRange found;

	unsigned i, j;
	for (i=0; i<100; i++)
	{
		NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

for (j=0; j<1024; j++)
{
found = [checker checkSpellingOfString:testString startingAt:0];
}


		NSLog(@"count %i",(i*1024 + j));
		[pool release];
	}


Hope that helps,

	Louis



Hi

I have written a little program to solve a word puzzle. The program puts together possible words by appending permutations of supplied letters and syllables.
To determine whether the resulting string is a valid word I and using NSSpellChecker


NSRange wordRange = [spellChecker checkSpellingOfString: string startingAt: 0];
if (wordRange.length == 0) {
NSlog([NSString stringWithFormat: @" %@ is a word", string]);
}


The problem is my program fails with
	Executable "MyApp" has exited due to signal 10 (SIGBUS).

after checking about 64,000 words. I guess it's hitting 64k (65,536) and this is some magic limit in NSSpellChecker.

Does anybody know how to reset whatever counter is causing NSSpellChecker to give up?
I thought at first it was accumulating a large ignored words list, so I added closeSpellDocumentWithTag but that didn't help, and I see that the ignored word list count is zero so that's not it.


Denis
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >NSSpellChecker crashes after 64k words (From: Denis Stanton <email@hidden>)
 >Re: NSSpellChecker crashes after 64k words (From: Dan Saul <email@hidden>)
 >Re: NSSpellChecker crashes after 64k words (From: Denis Stanton <email@hidden>)

  • Prev by Date: Re: NSSpellChecker crashes after 64k words
  • Next by Date: Re: ScrollBar Position
  • Previous by thread: Re: NSSpellChecker crashes after 64k words
  • Next by thread: Re: NSSpellChecker crashes after 64k words
  • Index(es):
    • Date
    • Thread