Core Data grinds for 30 min saving SQLite. 10.6 Bug?
Core Data grinds for 30 min saving SQLite. 10.6 Bug?
- Subject: Core Data grinds for 30 min saving SQLite. 10.6 Bug?
- From: Jerry Krinock <email@hidden>
- Date: Sun, 14 Apr 2013 17:25:26 -0700
With a particular data set, I can reproduce a behavior in Mac OS X 10.6.8 wherein -[NSManagedObjectContext save:] frantically writes and deletes a .sql-journal file for 28-30 minutes, as memory usage ramps up to 1.5 GB real + 3 GB virtual. Then, amazingly, malloc logs a message indicating inability to allocate memory, and then, even more amazingly, -save: returns, pointing to an error indicating that sqlite ran out of memory, and my process (a command-line tool) continues on its merry way. All of this happens on the main thread.
The subject Mac has a 32-bit Core Duo 2-core process with 2 GB RAM. I've not been able to reproduce this on a new Mac running Mac OS X 10.8. But all things are not quite equal, and I hesitate to close the case as a "10.6 Core Data bug", because the behavior is so incredible.
Has anyone ever seen any behavior like this? (More data follows below.)
Thanks,
Jerry Krinock
*******************
***** Error logged:
*******************
malloc: *** mmap(size=16777216) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
********************************************************
***** Error returned by -[NSManagedObjectContext save:]:
********************************************************
Code: 256
Domain: NSCocoaErrorDomain
Description: The file “MyFoo.sql” couldn’t be opened.
****************************************
***** Underlying error inside that error
****************************************
I/O error for database at /path/to/MyFoo.sql. SQLite error code:7, 'out of memory'
*************************************************************
***** Sample of what Core Data is doing during this half hour
*************************************************************
This was >3 times longer but I grepped out lines that counted less
than 5 samples to make it more readable.
1997 -[NSManagedObjectContext save:]
1961 -[NSPersistentStoreCoordinator(_NSInternalMethods) executeRequest:withContext:]
1953 -[NSSQLCore executeRequest:withContext:]
1951 -[NSSQLCore saveChanges:]
989 -[NSSQLCore performChanges]
964 -[NSSQLCore _performChangesWithAdapterOps:]
506 -[NSSQLConnection performAdapterOperations:]
505 -[NSSQLConnection performAdapterOperation:]
497 -[NSSQLiteConnection updateRow:]
235 -[NSSQLiteConnection execute]
225 _execute
223 sqlite3_step
220 sqlite3VdbeExec
161 sqlite3BtreeInsert
157 sqlite3PagerWrite
156 pager_write
154 unixWrite
152 pwrite$UNIX2003
27 sqlite3VdbeExec
9 allocateCursor
5 sqlite3VdbeMemGrow
6 btreeCursor:]
105 -[NSSQLiteConnection prepareSQLStatement:]
100 sqlite3LockAndPrepare
98 sqlite3RunParser
86 sqlite3Parser
82 yy_reduce
58 sqlite3Update
26 sqlite3WhereBegin
10 codeOneLoopStart
7 sqlite3ExprIfFalse
5 codeCompare
5 sqlite3WalkExpr
13 sqlite3Update
10 sqlite3FinishCoding
9 sqlite3VdbeMakeReady
7 sqlite3Expr
6 yy_reduce:](NSObject) retain]:]
53 -[NSSQLAdapter newUpdateStatementWithRow:]
22 -[_NSSQLGenerator prepareUpdateStatementWithRow:originalRow:]:]:]:atIndex:](NSObject) retain]:]:optLock:]:]:](NSObject) alloc](NSObject) allocWithZone:]:]:]:atIndex:](NSObject) retain]:]:]:](NSObject) alloc](NSObject) allocWithZone:](NSObject) release]:]:]:originalRow:]:]:]:]:]
9 -[_NSSQLGenerator dealloc]
5 _CFRelease(NSObject) dealloc](NSObject) dealloc](NSObject) release](NSObject) release]
7 -[NSSQLAdapter newGeneratorWithStatement:]:forAdapter:]:](NSObject) new](NSObject) alloc]:](NSObject) self](NSObject) alloc](NSObject) allocWithZone:]
6 -[NSSQLAdapter newStatementWithEntity:]:]:sqlString:]:](NSObject) alloc]:](NSObject) alloc](NSObject) allocWithZone:]:]
6 objc_msgSend:](NSObject) copy]:](NSObject) release]
21 objc_exception_throw
20 __raiseError
6 -[NSCFDictionary setObject:forKey:]:forKey:]
5 +[NSThread callStackReturnAddresses]:count:symbols:](NSObject) new](NSObject) alloc](NSObject) isKindOfClass:]:]
19 -[NSSQLiteConnection cacheUpdateStatement:forEntity:andDeltasMask:]
9 CFDictionarySetValue
9 CFBasicHashSetValue
8 __CFBasicHashAddValue(NSObject) retain]
5 CFDictionaryCreateMutable
5 __CFDictionaryCreateGeneric:forEntity:andDeltasMask:]
15 -[NSSQLiteConnection resetSQLStatement]
10 sqlite3_reset
5 sqlite3VdbeReset(NSObject) release]
14 -[NSSQLRow newCalculatedDeltaMaskFrom:]
9 __CFBitVectorInit
6 _CFRuntimeCreateInstance
5 _CFRuntimeCreateInstance:]:]
6 objc_msgSend
5 -[NSSQLiteConnection _clearBindVariablesForUpdateStatement:forDeltasMask:]:forDeltasMask:]:](NSObject) release]
5 -[NSSQLiteConnection cachedUpdateStatementForEntity:andDeltasMask:]
5 CFDictionaryGetValue
5 CFSetAddValue
5 CFBasicHashAddValue(NSObject) retain]:andOriginalRow:forDeltasMask:]:andOriginalRow:forDeltasMask:]:reason:userInfo:]:reason:userInfo:]:reason:userInfo:]:]:]:]:after:]:after:]:timestamp:]
7 objc_msgSend
428 -[NSSQLCore _performExhaustiveConflictDetectionForObjects:withChannel:]
317 -[NSSQLCore _rowsForConflictDetection:withChannel:]
262 -[NSSQLiteConnection rawIntegerRowsForSQL:]
158 sqlite3_step
156 sqlite3VdbeExec
43 sqlite3VdbeHalt
41 sqlite3BtreeClose
30 sqlite3PagerClose
14 sqlite3PcacheTruncate
13 pcache1Truncate
8 pcache1Truncate
8 pcache1Destroy
8 sqlite3BtreeRollback
36 sqlite3VdbeExec
23 sqlite3BtreeInsert
9 sqlite3PageMalloc
5 mallocWithAlarm
5 sqlite3MemMalloc
19 sqlite3BtreeBeginTrans
18 sqlite3PagerAcquire
11 sqlite3PcacheFetch
5 pcache1Create
7 __bzero
8 sqlite3BtreeFactory
7 allocateCursor
5 sqlite3VdbeMemGrow
7 btreeCreateTable
6 allocateBtreePage
5 sqlite3BtreeCloseCursor
79 sqlite3LockAndPrepare
76 sqlite3RunParser
69 sqlite3Parser
68 yy_reduce
50 sqlite3Select
17 sqlite3WalkSelect
9 resolveSelectStep
15 sqlite3WhereBegin
7 bestIndex
6 bestIndex
6 selectInnerLoop
8 yy_reduce
10 CFArrayAppendValue
9 _CFArrayReplaceValues(NSStringOtherEncodings) UTF8String]:]
33 -[NSString initWithFormat:]
33 -[NSPlaceholderString initWithFormat:locale:arguments:]
33 _CFStringCreateWithFormatAndArgumentsAux
27 _CFStringAppendFormatAndArgumentsAux
12 _CFStringAppendFormatAndArgumentsAux
7 __CFStringAppendBytes
5 __CFStringChangeSizeMultiple
7 snprintf_l
6 __vfprintf
11 +[NSString stringWithFormat:]
11 -[NSPlaceholderString initWithFormat:locale:arguments:]
11 _CFStringCreateWithFormatAndArgumentsAux
7 _CFStringAppendFormatAndArgumentsAux:]:](NSObject) alloc]:]:]:]:]:]
39 +[_PFRoutines _groupObjectsByRootEntity:]
8 -[NSSet allObjects]
5 +[NSArray arrayWithObjects:count:]
5 -[__NSPlaceholderArray initWithObjects:count:]:count:]:]
6 -[NSCFArray addObject:]:atIndex:]
5 -[NSCFDictionary setObject:forKey:]:]
5 -[NSDictionary allValues]:count:]:count:]:]:](NSObject) alloc]:]:]:]:]:](_NSInternalMethods) _rootEntity]
24 -[NSSQLCore fetchRowForObjectID:]
18 -[NSSQLCore newRowsForFetchPlan:]
17 -[NSSQLCore _newRowsForFetchPlan:selectedBy:withArgument:]
8 -[NSSQLCore _prepareResultsFromResultSet:usingFetchPlan:withMatchingRows:]:forObjectID:options:]:](_NSInternalMethods) objectIDFactoryForEntity:]:]:count:]:withObject:]:count:andFlags:]:]:]:](NSObject) alloc](NSObject) alloc](NSObject) allocWithZone:](NSObject) dealloc](NSObject) release]
20 -[NSArray sortedArrayUsingFunction:context:]
20 -[NSArray sortedArrayWithOptions:usingComparator:]
10 CFSortIndexes
6 malloc_zone_memalign
5 szone_memalign
6 +[NSArray arrayWithObjects:count:]
5 -[__NSPlaceholderArray initWithObjects:count:]:count:](NSObject) alloc]:]:usingComparator:]
14 objc_msgSend
8 -[NSSQLCore _newConflictRecordForObject:originalRow:newRow:]
5 -[NSSQLCore _newObjectGraphStyleForSQLRow:withObject:]:]:entity:]:](_NSInternalMethods) objectIDFactoryForEntity:](_NSInternalMethods) faultHandler]:withObject:]:]:forKey:]:count:]:count:](NSObject) alloc]:]
14 -[NSCFSet unionSet:]
9 CFSetAddValue
9 CFBasicHashAddValue
8 __CFBasicHashAddValue:]:forKey:]:forKeys:count:]:]:reason:userInfo:]:reason:userInfo:](NSObject) alloc]:]
20 -[NSSQLCore beginTransaction]
20 -[NSSQLiteConnection beginTransaction]
14 -[NSSQLiteConnection _executeSQLString:]
12 sqlite3_step
12 sqlite3VdbeExec
11 sqlite3BtreeBeginTrans
11 pager_open_journal
6 writeJournalHdr
6 unixWrite
6 pwrite$UNIX2003
5 unixOpen$UNIX2003$UNIX2003
6 -[NSSQLConnection transactionDidBegin]
6 -[NSNotificationCenter postNotificationName:object:]
5 -[NSNotificationCenter postNotificationName:object:userInfo:]:object:userInfo:]
913 -[NSSQLCore rollbackChanges]
883 -[NSSQLiteConnection rollbackTransaction]
819 -[NSSQLiteConnection _executeSQLString:]
813 sqlite3_step
813 sqlite3VdbeExec
812 sqlite3RollbackAll
811 sqlite3BtreeRollback
463 sqlite3PagerRollback
463 pager_playback
430 pager_end_transaction
350 unixDelete
350 unlink
349 __unlink
79 closeUnixFile
78 close$UNIX2003
15 pager_playback_one_page
15 unixRead
15 pread$UNIX2003
9 readMasterJournal
7 unixRead
7 pread$UNIX2003$INODE64
6 readJournalHdr
6 unixRead
6 pread$UNIX2003$INODE64
336 pager_end_transaction
308 unixDelete
308 unlink
290 __unlink
18 __compare_and_swap64
20 _posixUnlock
20 fcntl$UNIX2003$UNIX2003
9 pager_unlock
8 _posixUnlock
6 fcntl$UNIX2003
47 -[NSSQLiteConnection _clearTransactionCaches]
25 CFDictionaryRemoveAllValues
25 __CFBasicHashDrain
22 __CFDictionaryCallback
22 _CFRelease
20 __CFBasicHashDrain
15 __CFDictionaryCallback
12 CFRelease
9 -[NSSQLiteStatement dealloc]
9 -[NSSQLStatement dealloc]
9 _CFRelease
8 __CFArrayReleaseValues
7 CFRelease
5 -[NSObject(NSObject) release]
5 __CFDoExternRefOperation
5 CFBasicHashRemoveValue
5 ___CFBasicHashFindBucket1(NSObject) dealloc](NSObject) release]
8 CFBasicHashRemoveValue
5 __CFSetCallback(NSObject) release]
7 -[NSSQLiteStatement clearCaches]
7 sqlite3_finalize
7 sqlite3VdbeDelete
15 -[NSSQLConnection transactionDidRollback]
13 -[NSNotificationCenter postNotificationName:object:]
9 -[NSNotificationCenter postNotificationName:object:userInfo:]
7 _CFXNotificationPostNotification
6 __CFXNotificationPost:object:userInfo:]:](NSObject) dealloc](NSObject) release](NSObject) release]
28 -[NSSQLCore _cleanUpAfterSave]
28 _CFRelease
28 __CFBasicHashDrain
27 __CFDictionaryCallback
25 CFRelease
18 -[NSSQLOperation dealloc]
8 _CFRelease
7 __CFArrayReleaseValues(NSObject) release]
5 -[NSExternalRefCountedData release]
5 -[NSSQLRow dealloc](NSObject) dealloc](NSObject) release]
35 -[NSAutoreleasePool drain]
35 NSPopAutoreleasePool
35 _CFAutoreleasePoolPop
23 _CFRelease
14 __CFArrayReleaseValues
9 CFRelease
6 -[NSSQLAdapterOperation dealloc]
6 -[NSExternalRefCountedData release]
6 -[NSSQLRow dealloc]
5 _NSQLRow_dealloc_standard(NSObject) release]
5 szone_free
9 CFRelease
5 -[NSException dealloc](NSObject) dealloc](NSObject) dealloc](NSObject) release]
5 -[NSSQLCore recordChangesInContext:]:]:withObject:]:]:withObject:]:withOperation:]:]:copyItems:]:count:]:](NSObject) retain]:]:]:]
5 -[NSPersistentStore(_NSInternalMethods) _preflightCrossCheck]$INODE64(NSPathUtilities) fileSystemRepresentation]:]:maxLength:withPath:](NSObject) autorelease](_NSInternalMethods) _checkRequestForStore:originalRequest:andOptimisticLocking:](_NSInternalMethods) _conflictsWithRowCacheForObject:andStore:]
27 -[NSManagedObjectContext(_NSInternalChangeProcessing) _prepareForPushChanges:]
27 -[NSManagedObjectContext(_NSInternalAdditions) _validateChangesForSave:]
25 -[NSManagedObjectContext(_NSInternalAdditions) _validateObjects:forOperation:error:exhaustive:forSave:]
22 -[NSManagedObject validateForUpdate:]
21 -[NSManagedObject(_NSInternalMethods) _validateForSave:]
20 -[NSManagedObject(_NSInternalMethods) _validatePropertiesWithError:]
14 -[NSManagedObject(_NSInternalMethods) _validateValue:forProperty:andKey:withIndex:error:]
5 -[NSRelationshipDescription(_NSInternalMethods) _nonPredicateValidateValue:forKey:inObject:error:](_NSInternalMethods) _nonPredicateValidateValue:forKey:inObject:error:](_NSInternalMethods) _validateValuesAreOfDestinationEntity:source:](_NSInternalMethods) _nonPredicateValidateValue:forKey:inObject:error:](_NSInternalMethods) _nonPredicateValidateValue:forKey:inObject:error:](_NSInternalMethods) _nonPredicateValidateValue:forKey:inObject:error:](_NSInternalMethods) _validateValue:forProperty:andKey:withIndex:error:](_NSInternalMethods) _validatePropertiesWithError:]:](_NSInternalAdditions) _validateChangesForSave:]
5 -[NSMergePolicy resolveConflicts:]:]:]:](NSObject) dealloc]
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden