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


Groups > comp.lang.c > #11967

Re: Competing criteria

From Richard Damon <news.x.richarddamon@xoxy.net>
Newsgroups comp.lang.c
Subject Re: Competing criteria
Date 2011-10-22 16:47 -0400
Organization A noiseless patient Spider
Message-ID <j7va52$dkp$1@dont-email.me> (permalink)
References <b512b55a-437a-4ba2-97cd-c483e7449492@g7g2000vbv.googlegroups.com> <slrnja3ram.2b68.usenet-nospam@guild.seebs.net> <e216a71kb5i68vtaas07l9sgprnoh1lgs4@4ax.com>

Show all headers | View raw


On 10/22/11 2:06 PM, Roberto Waltman wrote:
> Seebs  wrote:
>>   the canonical
>> solution to "not heap allocation" is to define a reasonable maximum count
>> of simultaneous objects, statically allocate them, and then basically
>> write your own mini-allocator that keeps track of which ones you're using.
>> This, you will note, is probably stupid.
>
> Far from being stupid, that is the only way you can guarantee that
> memory allocation will not fail due to memory fragmentation, in
> systems with limited resources, no virtual memory and that must run
> 24/7.
> --
> Roberto Waltman
>

As I mentioned last night, that isn't totally true. It can be generally 
considered safe to do heap allocation during initial startup (for 
buffers that will then live forever, perhaps handed out and collected 
with allocation functions.

While in principle, it would normally be possible to rewrite all the 
code that uses the heap to use statically allocated buffers, this often 
forces details of implementation to leak out, especially of objects that 
need internal buffers that can't be fixed in size over all uses.

It can also be acceptable to heap allocations for non-critical 
operations that are allowed to fail or be postponed for arbitrary 
periods of time. These allocations should be for a limited period of 
time, and it is desirable for there to be occasional times when most of 
these are all released at the same time to let the heap defragment.

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


Thread

Competing criteria nroberts <roberts.noah@gmail.com> - 2011-10-21 14:49 -0700
  Re: Competing criteria Seebs <usenet-nospam@seebs.net> - 2011-10-21 22:16 +0000
    Re: Competing criteria Roberto Waltman <usenet@rwaltman.com> - 2011-10-22 14:06 -0400
      Re: Competing criteria Richard Damon <news.x.richarddamon@xoxy.net> - 2011-10-22 16:47 -0400
        Re: Competing criteria Ark <akhasin@macroexpressions.com> - 2011-10-22 17:33 -0400
          Re: Competing criteria Richard Damon <news.x.richarddamon@xoxy.net> - 2011-10-22 18:20 -0400
            Re: Competing criteria Ark <akhasin@macroexpressions.com> - 2011-10-22 21:29 -0400
            Re: Competing criteria "io_x" <a@b.c.invalid> - 2011-10-23 10:32 +0200
              Re: Competing criteria "Joachim Schmitz" <nospam.jojo@schmitz-digital.de> - 2011-10-23 11:06 +0200
                Re: Competing criteria Willem <willem@toad.stack.nl> - 2011-10-23 09:09 +0000
                Re: Competing criteria "io_x" <a@b.c.invalid> - 2011-10-23 12:04 +0200
                Re: Competing criteria "io_x" <a@b.c.invalid> - 2011-10-27 08:44 +0200
                Re: Competing criteria Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-10-23 05:01 -0700
            Re: Competing criteria Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-10-23 08:29 -0400
              Re: Competing criteria Richard Damon <news.x.richarddamon@xoxy.net> - 2011-10-23 09:15 -0400
                Re: Competing criteria Malcolm McLean <malcolm.mclean5@btinternet.com> - 2011-10-23 06:24 -0700
                Re: Competing criteria Markus Wichmann <nullplan@gmx.net> - 2011-10-24 22:39 +0200
                Re: Competing criteria Keith Thompson <kst-u@mib.org> - 2011-10-24 17:10 -0700
                Re: Competing criteria Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2011-10-25 13:09 +0300
                Re: Competing criteria Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-10-26 00:23 -0700
      Re: Competing criteria Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2011-10-23 00:02 +0300
      Re: Competing criteria Seebs <usenet-nospam@seebs.net> - 2011-10-24 20:10 +0000
        Re: Competing criteria Richard Damon <news.x.richarddamon@xoxy.net> - 2011-10-24 19:36 -0400
        Re: Competing criteria nroberts <roberts.noah@gmail.com> - 2011-10-25 10:07 -0700
          Re: Competing criteria Richard Damon <news.x.richarddamon@xoxy.net> - 2011-10-25 16:51 -0400
  Re: Competing criteria John Gordon <gordon@panix.com> - 2011-10-21 22:37 +0000
  Re: Competing criteria Richard Damon <news.x.richarddamon@xoxy.net> - 2011-10-21 20:42 -0400

csiph-web