English 中文(简体)
Core Data Malloc Errors
原标题:

I ve noticed I m getting a few errors at random points in my app. I ve had 2 errors, "double free" and "incorrect checksum for freed object". Heres the stack trace of a "double free" error. Can anyone provide any insight? It s happening on a call in my code that just sets an attribute to an NSNumber so I can t understand why it s doing it!

myObject.numberAttr = [NSNumber numberWithInt:[dateComponents day]];

Randomly Triggered (Doesn t always happen):

#0  0x9585b072 in malloc_error_break
#1  0x9585c218 in szone_error
#2  0x9585c34d in free_tiny_botch
#3  0x01c5e064 in _PFDeallocateObject
#4  0x01c97e2b in -[NSManagedObject(_NSInternalMethods) _setLastSnapshot__:]
#5  0x01c97a0d in -[NSManagedObjectContext(_NSInternalChangeProcessing) _establishEventSnapshotsForObject:]
#6  0x01c97866 in _PFFastMOCObjectWillChange
#7  0x01c976c5 in _PF_ManagedObject_WillChangeValueForKeyIndex
#8  0x01c97525 in _sharedIMPL_setvfk_core
#9  0x01c9b827 in _svfk_5

Many thanks,

Michael

最佳回答

I figured it out! It turns out that it was a threading issue with my managed object context. I was creating it on the main thread and using it on my background thread. However it would seem that the context has to be created and used all within 1 thread. Hope this helps anyone else who may come across this issue as the debugging information wasn t very clear!

问题回答

The "numberAttr" works like a property declared as retain, so when you change its value to reference a different NSNumber object, the previous NSNumber object will be sent a release message. I would expect to see this behavior if that previous object had already been released.

Do you have other places that you are setting "numberAttr"? Is it possible that one of those NSNumber objects has been released before you change the attribute here?





相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签