re: Locating managed objects within ObjectAlloc (was Re: Garbage collection, core data, and tight loops)
re: Locating managed objects within ObjectAlloc (was Re: Garbage collection, core data, and tight loops)
- Subject: re: Locating managed objects within ObjectAlloc (was Re: Garbage collection, core data, and tight loops)
- From: Ben Trumbull <email@hidden>
- Date: Sat, 3 Nov 2007 16:08:42 -0700
This sounds like caching behavior that I think I've observed. My app
create millions of managed objects during an import process, and I've
seen large memory usage that doesn't go down when the objects are
dealloced.
You mean RSIZE as reported by 'top', not malloc's free heap space as
reported by 'heap'.
Looking at backtraces in ObjectAlloc, I see a lot of
mallocs in caching functions as various objects are dealloc'ed. If I
close the NSPersistentDocument, I get some memory reclaimed, but not
what I expect. But, if I repeated run the import (without quitting),
the peak memory doesn't go up, so the memory is apparently reused.
Correct. The memory is freed (heap space), but not returned to the
kernel (VM mapping). This is the behavior of malloc on OSX. You will
see a high watermark effect.
This leads me to a question about using ObjectAlloc (in Instruments on
Leopard) effectively, especially with respect to Core Data. When
looking at allocations, there are a large number of GeneralBlocks of
various sizes, but no NSManagedObjects. I have some custom
subclasses, too, and those aren't identified either in the Categories
column. I want to observe the usage patterns of the various entities
in my model, but I'm not sure how to do that. Is there an easy way to
filter managed objects?
No, allocation events for managed objects are not currently tracked by
ObjectAlloc except as general blocks. The 'heap' and 'leaks' tools
both perceive managed objects. You'll probably find the 'heap' tool
useful for experimenting with these questions. Also, 'malloc_history'
is much improved on Leopard and often overlooked.
- Ben
_______________________________________________
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