Re: Policy on rebooting?

From: CBFalconer (cbfalconer_at_yahoo.com)
Date: 10/08/04

  • Next message: CBFalconer: "Re: OT:why a group of signals is called a bus?"
    Date: Fri, 08 Oct 2004 18:53:27 GMT
    
    

    "Michael N. Moran" wrote:
    >> Michael N. Moran wrote:
    >
    ... snip ...
    >>
    >> A production system should not have, what we called "memory block
    >> promotion" enabled. This is where a larger block is given when no
    >> more appropriate-size blocks are available. It is one of the hardest
    >> things to tune, but really necessary. I found that determining the
    >> appropriate sizes of the pools statically was impossible. Hence we
    >> did it with lots and lots of testing/tuning.
    >
    > It seems to me that such a system with "memory block promotion"
    > disabled is prone to behavior changes due to run-time variations in the
    > order in which blocks of various sizes are allocated. This could wildly
    > affect the memory usage efficiency, if several large blocks are
    > allocated and released before small blocks, and thus limiting the
    > number of small blocks available. Thus, determinism is affected.

    The problem is not the use of dynamic memory, the problem is
    fragmentation. Avoiding this doesn't require garbage collection,
    etc, in fact that is harmful. What is required is a means of
    avoiding fragmentation while preserving efficiency.

    What you can do (and I have in the past) is build an allocater that
    functions through indirect pointers, so that the allocation can be
    moved. Then a routine can be called periodically, basically in the
    idle time of the process, that advances one step towards complete
    defragmentation. That means find the lowest (or highest) portion,
    move it, and update what the indirect pointer points to. Sooner or
    later, barring continuous allocate/free, the memory will be
    compacted. So you usually have to be able to test whether there is
    sufficient memory when malloc fails, and just postpone something
    until it can succeed. My application timed out the use of the
    storage (which was a store and forward message system) and dumped
    the timed out message to the console with an undeliverable tag
    attached. So we were guaranteed eventual freeing of the storage.

    If you can guarantee that only one pointer to a particular block is
    in play at any time, you can, in the allocation supervisory block,
    replace the indirect table with a pointer back to the actual
    pointer. I hope that makes sense, but I am too lazy to make an
    ascii diagram.

    I repeat, dynamic memory is not the problem. Fragmentation is.

    -- 
    Chuck F (cbfalconer@yahoo.com) (cbfalconer@worldnet.att.net)
       Available for consulting/temporary embedded and systems.
       <http://cbfalconer.home.att.net>  USE worldnet address!
    

  • Next message: CBFalconer: "Re: OT:why a group of signals is called a bus?"

    Relevant Pages

    • Re: trying to make my "fillvalues" function work...
      ... void checkPtr_error(const char *location, const void *pointer) ... fprintf(stderr, "Memory allocation failure (%s). ...
      (comp.lang.c)
    • Re: various objects in my VB6 project - Calling IUnknown
      ... memory allocation and deallocation is half ... Doing something like this with a pointer would be a permanent leak in C++. ... Visual C++ has heap checking built ...
      (microsoft.public.vb.general.discussion)
    • Re: Linked List & Dynamic Memory Allocation
      ... you have a memory leak. ... that storage will not be available any longer. ... You must call freefor every pointer you got via malloc. ... There are three serious errors you can make using dynamic allocation: ...
      (microsoft.public.vc.mfc)
    • Re: memory
      ... statement caused a corruption of the free memory pool or allocated ... allocation routines so I could have access to the free memory pool and ... removing your internal copy of the pointer as you do. ... Dig the even newer still, yet more improved, sig! ...
      (comp.lang.c)
    • Re: sizeof(ptr) = ?
      ... used to point to different areas in memory. ... everyone else was talking about pointer that might be different ... I am going back, again, to the pointers being different sizes. ... If it became bigger than the char * above, I guess the cast to put it ...
      (comp.lang.c)