I love the ease with which I can do concurrency with Central Dispatch, but today I hit what looks like a strange snag. My program crashes when one of the job terminates. The place is not always the same, but it seems to go wrong while auto releasing memory. My threads do not share any memory whatsoever, so it's hard to see how it could interfere.
I do allocate a NSMutableDictionary in each thread like this:
mValuesTable = [ [ NSMutableDictionary dictionaryWithCapacity:32 ] retain ];
and free it like this in the destructor:
[ mValuesTable release ];
In the beginning of the application I do set an auto release pool as follows:
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
Is it possible that NSAutoreleasePool is not thread-safe? I find it hard to imagine, but wanted to make sure...
Any help is appreciated.
Mark
I do allocate a NSMutableDictionary in each thread like this:
mValuesTable = [ [ NSMutableDictionary dictionaryWithCapacity:32 ] retain ];
and free it like this in the destructor:
[ mValuesTable release ];
In the beginning of the application I do set an auto release pool as follows:
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
Is it possible that NSAutoreleasePool is not thread-safe? I find it hard to imagine, but wanted to make sure...
Any help is appreciated.
Mark