Permalink
Browse files

Fixed #23 Place @autoreleasepool in resource-hungry loops

  • Loading branch information...
1 parent 0df6841 commit c9f937cb9d8fe057aea0b7dafd97daefce705ea4 @tciuro committed Apr 17, 2012
Showing with 21 additions and 21 deletions.
  1. +2 −2 Classes/Public/NSFNanoSearch.m
  2. +19 −19 Classes/Public/NSFNanoStore.m
@@ -415,13 +415,13 @@ - (NSDictionary *)_retrieveDataAdded:(NSFDateMatchType)aDateMatch calendarDate:(
[searchResults setObject:[NSNull null] forKey:resultKey];
return searchResults;
} else {
- @autoreleasepool {
NSArray *resultsObjectClass = [result valuesForColumn:[NSString stringWithFormat:@"%@.%@", NSFKeys, NSFObjectClass]];
NSArray *resultsObjects = [result valuesForColumn:[NSString stringWithFormat:@"%@.%@", NSFKeys, NSFPlist]];
NSArray *resultsKeys = [result valuesForColumn:[NSString stringWithFormat:@"%@.%@", NSFKeys, NSFKey]];
NSUInteger i, count = [resultsKeys count];
- for (i = 0; i < count; i++) {
+ for (i = 0; i < count; i++) {
+ @autoreleasepool {
NSDictionary *info = [NSFNanoEngine _plistToDictionary:[resultsObjects objectAtIndex:i]];
if (nil != info) {
NSString *keyValue = [resultsKeys objectAtIndex:i];
@@ -1155,17 +1155,17 @@ - (BOOL)_addObjectsFromArray:(NSArray *)someObjects forceSave:(BOOL)forceSave er
_NSFLog(@" Done. Removing the objects took %.3f seconds", secondsRemoving);
// Store the objects...
- @autoreleasepool {
- BOOL transactionStartedHere = [self beginTransactionAndReturnError:nil];
-
- _NSFLog(@" Storing %ld objects...", unsavedObjectsCount);
-
- // Reset the default save interval if needed...
- if (0 == saveInterval) {
- self.saveInterval = 1;
- }
-
- for (id object in addedObjects) {
+ BOOL transactionStartedHere = [self beginTransactionAndReturnError:nil];
+
+ _NSFLog(@" Storing %ld objects...", unsavedObjectsCount);
+
+ // Reset the default save interval if needed...
+ if (0 == saveInterval) {
+ self.saveInterval = 1;
+ }
+
+ for (id object in addedObjects) {
+ @autoreleasepool {
// If the object was originally created by storing a class not recognized by this process, honor it and store it with the right class string.
NSString *className = nil;
if (YES == [object respondsToSelector:@selector(originalClassString)]) {
@@ -1203,14 +1203,14 @@ - (BOOL)_addObjectsFromArray:(NSArray *)someObjects forceSave:(BOOL)forceSave er
}
}
}
-
- // Commit the changes
- if (transactionStartedHere) {
- if (NO == [self commitTransactionAndReturnError:outError]) {
- [[NSException exceptionWithName:NSFNanoStoreUnableToManipulateStoreException
- reason:[NSString stringWithFormat:@"*** -[%@ %s]: %@", [self class], _cmd, [*outError localizedDescription]]
- userInfo:nil]raise];
- }
+ }
+
+ // Commit the changes
+ if (transactionStartedHere) {
+ if (NO == [self commitTransactionAndReturnError:outError]) {
+ [[NSException exceptionWithName:NSFNanoStoreUnableToManipulateStoreException
+ reason:[NSString stringWithFormat:@"*** -[%@ %s]: %@", [self class], _cmd, [*outError localizedDescription]]
+ userInfo:nil]raise];
}
}

0 comments on commit c9f937c

Please sign in to comment.