lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



On Sep 5, 2013 10:53 PM, "Tim Hill" <drtimhill@gmail.com> wrote:
[…]
> As for malloc(), nope, not confused at all, and while I am making a general assumption about malloc(), I've yet to find a help allocator underneath the C malloc() API that only allocates multiples of VM pages (I'm not sure when you mean "greater" granularity of you mean finer or coarser grained).

Sigh.

Whether or not malloc() organizes objects into buckets sized n^2, malloc() can only acquire multiples of pagesize of virtual memory at a time. One page can hold multiple objects.

In function ``f'',

int f()
{
    /*pa*/
    z = malloc(x);
    /*pb*/
}

i
L
L
f at pa the process has allocated n bytes, and malloc(x) is successful, then at pb the process vm will be  (n + x + PAGESIZE-1) & ~(PAGESIZE-1), in other words, rounded to the nearest greater pagesize multiple. Please show a system where this is false.

> --TIm
>
>
>