[PATCH] Add a malloc_usable_size_in_advance function
mh+jemalloc at glandium.org
Thu Feb 23 23:59:06 PST 2012
On Thu, Feb 23, 2012 at 05:06:27PM -0800, Jason Evans wrote:
> On 02/23/2012 11:23 AM, Mike Hommey wrote:
> >On Tue, Feb 21, 2012 at 05:39:10PM +0100, Mike Hommey wrote:
> >>From: Mike Hommey<mh at glandium.org>
> >> JEMALLOC_ATTR(visibility("default"))
> >>+JEMALLOC_P(malloc_usable_size_in_advance)(size_t size, size_t alignment)
> >>+ return (alignment == 0) ? s2u(size) : sa2u(size, alignment, NULL);
> >Both this and the "Use s2u in zone_good_size" patch don't work as
> Perhaps bad alignment values are being passed by your tests?
Actually, alignment is always 0 in my tests. I haven't even started to
check the results with alignment. The first thing that is striking is
that malloc_usable_size(malloc(0)) is 8, and s2u(0) doesn't return that.
> imemalign() does some validation of alignment before calling
> ipalloc()-->sa2u(), and similar validation should probably be done
> By the way, malloc_usable_size_in_advance() is a real mouthful. Is
> there precedence for that name? OS X has malloc_good_size(), which
> isn't great, but still a lot better.
We've been using malloc_usable_size_in_advance in Mozilla code, but it's
not something hard to change.
More information about the jemalloc-discuss