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


Groups > comp.lang.c > #107236

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

From Ian Collins <ian-news@hotmail.com>
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-28 13:35 +1300
Message-ID <ejtpdnFr72rU1@mid.individual.net> (permalink)
References <b89ce929-f3e4-45f5-9043-fed71931846b@googlegroups.com> <RJ-dndndsuhp0ETFnZ2dnUU7-bnNnZ2d@posted.internetamerica> <ef4e74be-c8cf-49d7-8a2a-b0e04ee8a962@googlegroups.com> <478jdc1tpnr7us6p6mgq95pdkql3ada5pp@4ax.com> <9e20418b-b66b-41c1-afbc-5e4f0a566d10@googlegroups.com>

Show all headers | View raw


On 03/28/17 01:31 PM, supercat@casperkitty.com wrote:
> On Monday, March 27, 2017 at 7:05:13 PM UTC-5, robert...@yahoo.com wrote:
>> On Mon, 27 Mar 2017 12:29:20 -0700 (PDT), supercat wrote:
>>> How often would programs request large amounts of memory that they never
>>> use outside of situations involving fork?  How often is fork() used in
>>> situations which wouldn't better be served by a system call that starts
>>> a new process along with calls to create, attach, and detach mutable or
>>> immutable shareable objects?
>>
>> It's not that uncommon to allocate a maximum sized area for some
>> process.  It's often easier to not have to deal with variable
>> allocations, and/or things that can grow and shrink.  Both are rather
>> less common in C++, where a bunch of the STL containers hide the
>> details from you.  I'm not saying it's a great technique, but it's far
>> from uncommon.
>
>> It's also very common to allocate large chunks of address space and
>> then suballocate them - that can lead to significant performance gains
>> in some situations.  Even the normal (small) heap allocation in malloc
>> work that way (malloc request large chunks of storage from the OS,
>> then hands out small chunks to the application).  Many contain objects
>> (including the STL ones) (can) allocate more than the minimum
>> increment needed when expanding a container.
>
> It's certainly common for programs to request large chunks from malloc() and
> then sub-allocate it, since an allocator that is designed around a program's
> particular usage patterns can often be more efficient than a general-purpose
> one like malloc().  Maybe it's common for Unix programs to allocate vastly
> more than they're likely ever to need, but I'm used to approaches that try
> to use an exponential-growth model to allocate a total amount that's within
> a constant factor of what's required.

Don't conflate Linux memory management with Unix: most (if not all) Unix 
systems stay well clear of over commit.

-- 
Ian

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