FROM : Denis Stanton
DATE : Wed Apr 13 22:38:51 2005
Hi Louis
I have finally found your response to my posting about SpellChecker.
You posting had been downloaded on my other so I didn't get it until
now. Fortunately there was enough info in the clippings that appeared
in follow-on mails for me to catch your suggestion that I needed to use
and NSAutoReleasePool and I skimmed forward in the book I'm reading to
find and example. Simple wrapping
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
.............
[pool release];
around to contents of each nested loop solved the problem.
Thanks for your help.
Denis
On Apr 14, 2005, at 7:02 AM, Denis Stanton wrote:
> Begin forwarded message:
>
>> From: "Louis C. Sacha" <<email_removed>>
>> Date: 12 April 2005 10:07:17 PM
>> To: <email_removed>
>> Cc: <email_removed>
>> Subject: Re: NSSpellChecker crashes after 64k words
>>
>> 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
>>
>>
> Denis Stanton
> <email_removed>
> Home: (09) 533 0391
> mobile: 021 1433622
>
Denis Stanton
Orcon Internet Limited
(09) 480 9299
http://www.orcon.net.nz
DATE : Wed Apr 13 22:38:51 2005
Hi Louis
I have finally found your response to my posting about SpellChecker.
You posting had been downloaded on my other so I didn't get it until
now. Fortunately there was enough info in the clippings that appeared
in follow-on mails for me to catch your suggestion that I needed to use
and NSAutoReleasePool and I skimmed forward in the book I'm reading to
find and example. Simple wrapping
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
.............
[pool release];
around to contents of each nested loop solved the problem.
Thanks for your help.
Denis
On Apr 14, 2005, at 7:02 AM, Denis Stanton wrote:
> Begin forwarded message:
>
>> From: "Louis C. Sacha" <<email_removed>>
>> Date: 12 April 2005 10:07:17 PM
>> To: <email_removed>
>> Cc: <email_removed>
>> Subject: Re: NSSpellChecker crashes after 64k words
>>
>> 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
>>
>>
> Denis Stanton
> <email_removed>
> Home: (09) 533 0391
> mobile: 021 1433622
>
Denis Stanton
Orcon Internet Limited
(09) 480 9299
http://www.orcon.net.nz
| 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

