This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Reducing memory consumption
- To: law at cygnus dot com
- Subject: Re: Reducing memory consumption
- From: "Martin v. Loewis" <martin at loewis dot home dot cs dot tu-berlin dot de>
- Date: Sun, 19 Mar 2000 21:42:16 +0100
- CC: mark at codesourcery dot com, gcc-patches at gcc dot gnu dot org
- References: <26555.953492393@upchuck>
> 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