Re: malloc_zone_batch_malloc
Re: malloc_zone_batch_malloc
- Subject: Re: malloc_zone_batch_malloc
- From: Ariel Burton <email@hidden>
- Date: Wed, 21 May 2008 21:26:43 -0400
Thanks.
It seems odd. I tried another machine, and like your
experience, it works.
This is what I see on the two machines:
i386-darwin-cereal % uname -a
Darwin cereal .totalviewtech.com 8.4.1 Darwin Kernel Version 8.4.1: Tue Jan 3 18:23:53 PST 2006; root:xnu-792.7.90.obj~1/RELEASE_I386 i386 i386
386-darwin-cereal% ./t_mailing_list_repro
do_experiment to size 16777216 returned 0
i386-darwin-wheat% uname -a
Darwin wheat.totalviewtech.com 9.0.0 Darwin Kernel Version 9.0.0: Tue Oct 9 21:35:55 PDT 2007; root:xnu-1228~1/RELEASE_I386 i386
386-darwin-wheat% ./t_mailing_list_repro
do_experiment to size 16777216 returned 1
What, I wonder, has changed?
Ariel
==
On Wed 21 May 17:35, Eric Gouriou wrote:
>
> On May 21, 2008, at 5:03 PM, Ariel Burton wrote:
> >The test program I included in my original
> >psoting, however, tries all sizes from 1 bytes
> >to 16mb without coming across a case where the
> >routine returns a non-zero value.
> >
> >Am I missing something?
>
> Works for me on Leopard 10.5.2 .
>
> ------
> // cc -Wall --std=c99 -o mzm mzm.c
> #include <stdio.h>
> #include <malloc/malloc.h>
>
> static size_t
> do_experiment (malloc_zone_t *z, size_t size_bound)
> {
> size_t ret_val = 0;
> void *v[ 2 ];
>
> for (size_t size = 1; size < size_bound; size++)
> {
> unsigned allocated = malloc_zone_batch_malloc ( z, size, v, 2 );
> if (allocated) {
> ret_val = size;
> break;
> }
> }
>
> return ret_val;
> } /* do_experiment */
>
> int
> main (int argc, const char *argv [])
> {
> size_t size_bound = 16 * 1024 * 1024;
> malloc_zone_t *z = malloc_default_zone();
>
> size_t size = do_experiment(z, size_bound);
>
> printf("do_experiment to size %zd returned %zd\n", size_bound, size);
>
> return 0;
> }
> -------
> % cc -Wall --std=c99 -o mzm mzm.c
> % ./mzm
> do_experiment to size 16777216 returned 1
> -------
>
> Of course I may have failed reading comprehension 201 this time
> around...
>
> Eric
>
> >Ariel Burton
> >==
> >On Wed 21 May 16:37, Terry Lambert wrote:
> >>
> >>On May 21, 2008, at 2:00 PM, Ariel Burton wrote:
> >>>In what circumstances is malloc_zone_batch_malloc
> >>>supposed to return any memory?
> >>
> >><http://developer.apple.com/documentation/Performance/Conceptual/ManagingMemory/Articles/MemoryAlloc.html
> >>>
> >>
> >>"f your code allocates multiple, identically-sized memory blocks, you
> >>can use the malloc_zone_batch_malloc function to allocate those
> >>blocks
> >>all at once. This function offers better performance than the
> >>equivalent series of calls to malloc to allocate the same memory.
> >>Performance is best when the individual block size is relatively
> >>small—
> >>less than 4K in size. The function does its best to allocate all of
> >>the requested memory but may return less than was requested. When
> >>using this function, check the return values carefully to see how
> >>many
> >>blocks were actually allocated."
> >>
> >>
> >>-- Terry
> >_______________________________________________
> >Do not post admin requests to the list. They will be ignored.
> >Darwin-dev mailing list (email@hidden)
> >Help/Unsubscribe/Update your Subscription:
> >
> >This email sent to email@hidden
>
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden