FROM : Louis C. Sacha
DATE : Tue Apr 12 12:07:17 2005
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
DATE : Tue Apr 12 12:07:17 2005
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
| Related mails | Author | Date |
|---|---|---|
| Denis Stanton | Apr 11, 02:35 | |
| Dan Saul | Apr 11, 18:22 | |
| Denis Stanton | Apr 12, 10:47 | |
| Louis C. Sacha | Apr 12, 12:07 | |
| The Karl Adam | Apr 12, 17:07 | |
| Evan DiBiase | Apr 12, 17:41 | |
| Louis C. Sacha | Apr 13, 01:02 | |
| Hamish Allan | Apr 13, 02:23 | |
| Denis Stanton | Apr 13, 06:20 | |
| Denis Stanton | Apr 13, 22:38 |






Cocoa mail archive

