Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 19 Jul 1999 12:44:03 -0400
From:      "Kelly Yancey" <kbyanc@alcnet.com>
To:        "Dag-Erling Smorgrav" <des@flood.ping.uio.no>
Cc:        <freebsd-hackers@freebsd.org>
Subject:   RE: Overcommit and calloc()
Message-ID:  <001f01bed205$e8aeecc0$291c453f@kbyanc.alcnet.com>
In-Reply-To: <xzp3dykmxo2.fsf@flood.ping.uio.no>

next in thread | previous in thread | raw e-mail | index | archive | help

  Ahh...but wouldn't the bzero() touch all of the memory just allocated
functionally making it non-overcommit? I realize that technically it isn't
the same since although calloc() would ensure the memory actually was
committed (again, since the bzero() touches all the pages), if there weren't
enough pages free then a random process would still be killed rather than
returning null.
  Believe me, I'm not trying to start that war again :) I'm just pointing
out that while technically it is still overcommit, it will touch the pages
ensuring that the memory does in fact exist (is committed). Perhaps this is
why I've always heard we should avoid calloc() because it is 'slow'?

  Thanks for the great feedback, I should kick myself for now digging my
hands in the mud myself (I assumed it was more complicated than that :) ).

  Kelly
 ~kbyanc@posi.net~
  FreeBSD - The Power To Serve - http://www.freebsd.org/
  Join Team FreeBSD - http://www.posi.net/freebsd/Team-FreeBSD


> -----Original Message-----
> From: Dag-Erling Smorgrav [mailto:des@flood.ping.uio.no]
> Sent: Monday, July 19, 1999 12:07 PM
> To: Kelly Yancey
> Cc: hackers@FreeBSD.ORG
> Subject: Re: Overcommit and calloc()
>
>
> "Kelly Yancey" <kbyanc@alcnet.com> writes:
> >   I'm afraid my question got lost amongst the see of overcommit
> messages. :)
> >   I was curious if calloc() was overcommitted also?
>
> Here's our calloc() implementation:
>
> void *
> calloc(num, size)
> 	size_t num;
> 	register size_t size;
> {
> 	register void *p;
>
> 	size *= num;
> 	if ( (p = malloc(size)) )
> 		bzero(p, size);
> 	return(p);
> }
>
> so the answer is yes, it overcommits, but the bzero() may cause the
> system to run out of swap.
>
> DES
> --
> Dag-Erling Smorgrav - des@flood.ping.uio.no
>



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?001f01bed205$e8aeecc0$291c453f>