Retain Cycles in Core Data
Retain Cycles in Core Data
- Subject: Retain Cycles in Core Data
- From: David Riggle <email@hidden>
- Date: Wed, 21 Nov 2007 13:07:56 -0800
I think my app is suffering from retain cycles in Core Data.
ObjectAlloc shows no leaks, but memory usage increases over time
without limit. The wasted memory is all in Core Data / SQLite "non-
objects". See the heap output below.
My object graph is very interconnected with numerous to-many and many-
to-many relationships. I've noticed memory usage increasing after
each executeFetchRequest I perform. I also do a lot of enumeration
through relationships in a given run loop, and my data is modified
frequently.
My app still needs to run on Tiger, so I can't use garbage
collection. I experimented with calling refreshObject:mergeChanges:
on the few objects that I retain, but it didn't make a difference. I
even turned on retainsRegisteredObjects, hoping the context would
eventually stop allocating memory, but that didn't help either.
I periodically save my database, so I could do a reset at that time,
but I would rather have the allocated memory be autoreleased
properly. How can I break the retain cycles so this can happen?
Dave
-----
Process 241: 1 zone
Zone DefaultMallocZone_0x300000: Overall size: 371696KB; 65179 nodes
malloced for 363277KB (97% of capacity); largest unused:
[0x018c7e00-7424KB]
Zone DefaultMallocZone_0x300000: 65179 nodes - Sizes: 340KB[1056]
96KB[1] 36KB[1] 20KB[2] 16KB[3] 11KB[2] 8KB[2] 8KB[3] 7KB[6] 6KB[1]
4KB[6] 3584[3] 3072[8] 2560[23] 2048[20] 1536[34] 1024[121] 512[25]
496[2] 480[10] 464[14] 448[12] 432[6] 416[5] 400[9] 384[14] 368[10]
352[5] 336[26] 320[23] 304[9] 288[27] 272[59] 256[37] 240[45] 224[51]
208[33] 192[83] 176[52] 160[56] 144[8288] 128[174] 112[171] 96[1062]
80[2261] 64[10335] 48[10809] 32[19797] 16[10377]
Found 2205 ObjC classes in process 241
-----------------------------------------------------------------------
Zone DefaultMallocZone_0x300000: 65179 nodes (371994640 bytes)
CLASS_NAME COUNT
BYTES AVG
========== =====
===== ===
<non-object> 39131
370932480 9479.2
NSCFString 11172
406064 36.3
NSCFArray 2252
48960 21.7
NSConcreteData 2123
70896 33.4
NSCFDictionary 1768
141744 80.2
NSCFData 729
42832 58.8
NSHTTPCookieInternal 684
43776 64.0
NSHTTPCookie 684
10944 16.0
NSKeyValueAccessor 664
31872 48.0
NSSQLObjectID 618
19776 32.0
NSCFNumber 588
9408 16.0
NSCFSet 480
26784 55.8
SyncableObjectMO 409
19632 48.0
_______________________________________________
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