Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #107206

Re: Does heap segment of a C program increases in the amount of RAM or is it fixed to a limit?

From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.c
Subject Re: Does heap segment of a C program increases in the amount of RAM or is it fixed to a limit?
Date 2017-03-27 21:17 +0100
Organization A noiseless patient Spider
Message-ID <87a8865vam.fsf@bsb.me.uk> (permalink)
References <b89ce929-f3e4-45f5-9043-fed71931846b@googlegroups.com> <ae725c7e-2bb1-09af-d1e7-2b52d2d5f30d@verizon.net>

Show all headers | View raw


"James R. Kuyper" <jameskuyper@verizon.net> writes:

> On 03/27/2017 04:23 AM, acidlategamer@gmail.com wrote:
> ...
>> 1.    Linux doesn't actually allocate your memory until you use it.
>>        int *p = malloc(sizeof(int));//memory is not used
>>        int *s = calloc(1, p);//memory is used
>
> That's a configurable option, called overcommit, and that's not a
> conforming implementation of malloc() when that option is turned on. I
> have it turned off on systems under my control.
>
>> 2.  When you use calloc instead of malloc, it zeroes out all the
>> memory you requested. This is equivalent to using it.
>
> It's not "equivalent" to using it; it IS using it.

Maybe in some theoretical way, yes, but surely the system can know that
the over-committed mapped pages will be zeroed?  On my Linux system,
repeatedly calloc does not grow the memory usage.  It's only when the
pages are touched by me (i.e. with an explicit write) that the memory
usage grows.

-- 
Ben.

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Does heap segment of a C program increases in the amount of RAM or is it fixed to a limit? acidlategamer@gmail.com - 2017-03-27 01:23 -0700
  Re: Does heap segment of a C program increases in the amount of RAM or is it fixed to a limit? "James R. Kuyper" <jameskuyper@verizon.net> - 2017-03-27 11:06 -0400
    Re: Does heap segment of a C program increases in the amount of RAM or is it fixed to a limit? Ken Brody <kenbrody@spamcop.net> - 2017-03-27 14:50 -0400
    Re: Does heap segment of a C program increases in the amount of RAM or is it fixed to a limit? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-03-27 21:17 +0100
      Re: Does heap segment of a C program increases in the amount of RAM or is it fixed to a limit? Robert Wessel <robertwessel2@yahoo.com> - 2017-03-27 19:08 -0500
  Re: Does heap segment of a C program increases in the amount of RAM or is it fixed to a limit? scott@slp53.sl.home (Scott Lurndal) - 2017-03-27 15:23 +0000
    Re: Does heap segment of a C program increases in the amount of RAM or is it fixed to a limit? "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2017-03-27 09:57 -0700
      Re: Does heap segment of a C program increases in the amount of RAM or is it fixed to a limit? BartC <bc@freeuk.com> - 2017-03-27 18:14 +0100
  Re: Does heap segment of a C program increases in the amount of RAM or is it fixed to a limit? gordonb.l1p2g@burditt.org (Gordon Burditt) - 2017-03-27 12:37 -0500
    Re: Does heap segment of a C program increases in the amount of RAM or is it fixed to a limit? "James R. Kuyper" <jameskuyper@verizon.net> - 2017-03-27 13:53 -0400
    Re: Does heap segment of a C program increases in the amount of RAM or is it fixed to a limit? scott@slp53.sl.home (Scott Lurndal) - 2017-03-27 18:06 +0000
    Re: Does heap segment of a C program increases in the amount of RAM or is it fixed to a limit? supercat@casperkitty.com - 2017-03-27 12:29 -0700
      Re: Does heap segment of a C program increases in the amount of RAM or is it fixed to a limit? Robert Wessel <robertwessel2@yahoo.com> - 2017-03-27 19:04 -0500
        Re: Does heap segment of a C program increases in the amount of RAM or is it fixed to a limit? supercat@casperkitty.com - 2017-03-27 17:31 -0700
          Re: Does heap segment of a C program increases in the amount of RAM or is it fixed to a limit? Ian Collins <ian-news@hotmail.com> - 2017-03-28 13:35 +1300
        Re: Does heap segment of a C program increases in the amount of RAM or is it fixed to a limit? Ian Collins <ian-news@hotmail.com> - 2017-03-28 13:37 +1300

csiph-web