This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Reducing memory consumption


> go look at how valloc works when you ask for a page of memory :(. 

You are talking about BSD valloc here, right? Which is

void *
valloc(i)
        size_t i;
{
        long valsiz = getpagesize(), j;
        void *cp = malloc(i + (valsiz-1));

        j = ((long)cp + (valsiz-1)) &~ (valsiz-1);
        return ((void *)j);
}

OTOH, glibc valloc is implemented as memalign(pagesize,n), which is
documented as

    memalign requests more than enough space from malloc, finds a spot
    within that chunk that meets the alignment request, and then
    possibly frees the leading and trailing space.

So perhaps it is not a good idea to use valloc, then, and instead
allocate more than one page at a time using malloc?

> Yes, this really happens.  To bootstrap on those boxes I have to turn on
> always collect and usually make the collection threshold very small.

I can see the problem with the overhead of having page-aligned memory
on systems which don't really support that. However, I don't see how
garbage collection would increase memory consumption apart from that.

Regards,
Martin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]