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: Sun, 4 Nov 2007 14:36:23 -0800
On Nov 4, 2007, at 3:27 AM, email@hidden wrote:
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.
I've read that, but forgot to consider it in this case. However,
I'm confused by the test case below. When the memory is malloc'ed,
VSIZE goes up. When the memory is used, RSIZE goes up. When the
memory is freed, both VSIZE and RSIZE go back down. Does this
contradict what you are saying?
No. The relationship is more complicated. For large blocks of
memory, malloc will return the allocation back to the kernel. For
small blocks, it will not, but instead coalesce the free space for
reuse later. The objects used in Core Data are almost exclusively
small. Amit Singh's book describes the malloc algorithms in
considerable detail.
<http://www.amazon.com/Mac-OS-Internals-Systems-Approach/dp/0321278542/ref=sr_1_1/103-1158819-7883057?ie=UTF8&s=books&qid=1194215432&sr=1-1
>
ptr = malloc(10 * 1024 * 1024);
Try again with something closer to the size of your managed objects.
Like 96-256 bytes.
Generally, I find RSIZE to reflect the high watermark of the process,
and use 'heap' to examine the currently free space within it. Your
mileage may vary. There's some pretty vociferous disagreement over
the "ideal" way to measure memory utilization (available v.s. vm
deallocated v.s. internal fragmentation, etc)
- 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