FROM : Ben Trumbull
DATE : Sun Nov 04 23:36:23 2007
On Nov 4, 2007, at 3:27 AM, ajb.<email_removed> 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
DATE : Sun Nov 04 23:36:23 2007
On Nov 4, 2007, at 3:27 AM, ajb.<email_removed> 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
| Related mails | Author | Date |
|---|---|---|
| ajb.lists | Nov 3, 16:41 | |
| Ben Trumbull | Nov 4, 00:08 | |
| ajb.lists | Nov 4, 12:27 | |
| Ben Trumbull | Nov 4, 23:36 | |
| Aaron Burghardt | Nov 5, 04:01 | |
| Chris Hanson | Nov 5, 04:28 |






Cocoa mail archive

