Re: [RFC] how to get the size of a malloc(9) block ?

From: Luigi Rizzo <rizzo_at_iet.unipi.it>
Date: Fri, 29 Nov 2013 17:11:49 -0800
On Fri, Nov 29, 2013 at 4:49 PM, Adrian Chadd <adrian_at_freebsd.org> wrote:

> The reason I wouldn't implement this is to avoid having code that
> _relies_ on this behaviour in order to function or perform well.
>


nobody ever said (or could reasonably expect to do) that.

Applications don't know if the allocator overallocates,
so they have no hope unless they work even without the feature.

This is only about giving them an option to improve
performance in those (rare ?) cases where, as i showed,
knowing the underlying allocation size may lead to
better usage of memory.


>
> Heck, it may not even be portable to other operating systems. Except,
> Linux, I guess.
>
>
in userspace, as jb commented, all major OSes have it
(malloc_usable_size() on FreeBSD and Linux,
_msize() on Windows, malloc_size() on OSX).


In the kernel, I have no idea, but porting kernel code
across systems is a nightmare anyways...

cheers
luigi
Received on Sat Nov 30 2013 - 00:11:53 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:44 UTC