Garbage Collection and NSManagedObject
Garbage Collection and NSManagedObject
- Subject: Garbage Collection and NSManagedObject
- From: Samuel Strupp <email@hidden>
- Date: Thu, 12 Feb 2009 15:52:24 +0100
Hi guys
i have problem with the garbage collector. May App is a CoreData App
(not document based). If i try to change the database and load a new
one. The grabage collector collects the old NSMangedObjects from the
old store. But this happens in the gabage collector thread. The
mainThread is executing, too. So some of the managed objects will be
finalized after the deletion of the database. This results in an
exception like this:
GC: -finalize resulted in an exception (0x1477cd0) being thrown, break
on objc_exception_during_finalize_error to debug
The NSManagedObject with ID:XXX <XXX> has been invalidated.
The main problem is that such objects seems to get observer messages
and then they will hang up the app if they try to access there
parameters from the store.
One solution would be to perform the gabage collection in the main
thread. But I don't know how.
Another solution should be to wait for the gabage collector until it
is finished with somethig stupid like this:
while ([[NSGarbageCollector defaultCollector] isCollecting]) {
[NSThread sleepForTimeInterval:0.5];
}
But this hangs up the app, too. I don't know why!
So has somebody a solution or idea for this garbage collector problem?
Thanks & Regrads
Samuel Strupp
_______________________________________________
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