Re: execution time becomes unpredictable?!



websnarf@xxxxxxxxx wrote:
>
.... snip ...
>
> Basically the C language standard does not mandate anything about
> performance and real implementations of memory heaps *really do*
> execute in unpredictable amounts of time. That said, there certainly
> do exist O(1) implementations of malloc/free (and realloc, if we ignore
> the memcpy overhead.) So malloc() is only slow on *some* systems --
> but it may be hard to know which such systems. As far as I know, gcc,
> because its open source and "Lea" malloc implementation is reasonably
> documented, we know that its memory allocation scheme is fairly
> reasonable. OTOH, I've measured MSVC's memory allocation speed, and
> its *MUCH* faster than gcc, but since its closed source, I can't sit
> here and tell you that its even O(1) in all cases.

Do try to be reasonably accurate. malloc is a part of the library,
so it has nothing to do with either gcc or MSVC, but everything to
do with the runtime library. Both sources (many in the case of
gcc) are available, but the MSVC stuff cannot be published without
permission. gcc operates on many systems with different
libraries. MSVC operates on an x86 under Windoze only. Depending
on where malloc gets the memory to hand out, the execution time can
be perfectly predictable, or at least have an upper bound put to
it. The time binds appear during free.

In practice you can often play implementor and link in a new malloc
package before linking the runtime library. There are no
guarantees once you do this.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson


.



Relevant Pages

  • Re: Dealing with naive malloc() implementations
    ... Were there implementations where this strategy (or something ... A "buddy system" malloc ... fragmentation can cause allocation failure when memory is ... but at a PPOE I did a fairly sizeable amount of work ...
    (comp.lang.c)
  • Re: C 99 compiler access
    ... > nm> reliably allocating some piece of memory. ... We're not talking about implementing malloc in portable C - it's part of the ... concern is that library implementations are not implementing the required ... using malloc to allocate the buffer memory. ...
    (comp.lang.c)
  • Re: Heap & BSS
    ... malloc() implementations that use mmapand munmapor similar. ... Such complaints are sometimes answered with "alas, the memory ... Reading email is like searching for food in the garbage, ...
    (comp.lang.c)
  • Re: Malloc()/Free()..Why it need more memory when there is available freed list?
    ... I have tried a little test about malloc and free function on Linux. ... the first vector and allocate them again. ... If freereally makes the memory available for next malloc, ... It doesn't have any relation with gcc, malloc, realloc, calloc and free ...
    (comp.unix.programmer)
  • Re: Can malloc ever really fail?
    ... > You cannot access memory outside of the chunk returned by malloc(). ... was probably a consequence of different existing implementations. ... reduce the actual memory usage to just the normal overhead. ...
    (comp.lang.c)