This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Reducing memory consumption
- To: "Martin v. Loewis" <martin at loewis dot home dot cs dot tu-berlin dot de>
- Subject: Re: Reducing memory consumption
- From: Jeffrey A Law <law at cygnus dot com>
- Date: Mon, 20 Mar 2000 10:52:17 -0700
- cc: mark at codesourcery dot com, gcc-patches at gcc dot gnu dot org
- Reply-To: law at cygnus dot com
In message <200003192042.VAA00809@loewis.home.cs.tu-berlin.de>you write:
> > 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);
> }
Right. Now go peek at how malloc handles a 2 * pagesize - 1 byte request
and start crying... Ugh, I forgot both valloc & malloc add their own
(significant) overhead to these kinds of requests.
> So perhaps it is not a good idea to use valloc, then, and instead
> allocate more than one page at a time using malloc?
Possibly. Alexandre has a patch which does this I think and I'm
planning to try it next time I try to bootstrap the m68k port on my
BSD boxes.
jeff