Re: Policy on rebooting?

From: Michael N. Moran (mike_at_mnmoran.org)
Date: 10/07/04


Date: Thu, 07 Oct 2004 07:38:43 -0400

D. Zimmerman wrote:
> Paul Keinanen wrote:
>
>> On Wed, 6 Oct 2004 11:16:58 +0200, "mk" <REVERSE_lp.pw@myzskm.REMOVE>
>> wrote:
>>
>>
>>> Why is dynamic memory allocation bad idea?
>>
>>
>>
>> Fragmentation.
>>
>
> This also depends on the operating system being used. Most real time
> OS's, which are often used for embedded, will only allocate fixed size
> memory blocks and will reclaim the entire block. This prevents the
> problem Paul described.

This does not *prevent* the problem, it only limits/slows the problem
if the application has a particular pattern of dynamic memory usage.

Imagine a limited supply of large fixed size blocks. If these blocks
are allocated and released and then subsequently allocated and
fragmented to fulfill the needs of another part of the system
requiring a smaller block size (of which there are no more), then
eventually such an allocation system will fail as well.

Of course, we're talking about general malloc/free new/delete here,
not private memory pools, which are pre-allocated for a particular
part of the system with fixed sized blocks.

What's more is that block memory allocation schemes reduce the
"memory efficiency" advantages of dynamic memory allocation by
wasting the unused portion of each allocated block.

BTW, allocation is not the issue. If memory is never freed,
then fragmentation will not happen. Of course, then its not
*really* dynamic.

-- 
Michael N. Moran           (h) 770 516 7918
5009 Old Field Ct.         (c) 678 521 5460
Kennesaw, GA, USA 30144    http://mnmoran.org
"... abstractions save us time working, but they don't
  save us time learning."
Joel Spolsky, The Law of Leaky Abstractions
The Beatles were wrong: 1 & 1 & 1 is 1


Relevant Pages

  • Re: How to release heap memory that is marked as free
    ... As I said, fragmentation is a very serious problem, and one of the most serious problems ... my allocator was accused of using massive amounts of memory. ... I'm going to have to re-think the memory allocation that I'm ... process's 'working set'. ...
    (microsoft.public.vc.mfc)
  • Re: [PATCH 00/28] Swap over NFS -v16
    ... memory they can consume. ... So we need the extra (skb) ... included in the reserve? ... if the allocation had to dip into emergency reserves, ...
    (Linux-Kernel)
  • Re: Memory leak with CAsyncSocket::Create
    ... read my essay on how storage allocators work. ... Create method is consuming system memory that is not released back to ... The memory consumption is either shown as "Mem Usage" on the Task ... many levels of allocation going ...
    (microsoft.public.vc.mfc)
  • Re: OT: C++ overloading operators
    ... dynamic allocation, no matter how many "clever tricks" are used... ... though there's enough memory in the system, ... all these "flexible data types" map into CPU command ... The computing environment is completely ...
    (comp.dsp)
  • Re: Memory leak with CAsyncSocket::Create
    ... socket is properly closed and deallocated between calls. ... memory creep in my system. ... because this is really indicating fragmentation (I suppose you ... many levels of allocation going ...
    (microsoft.public.vc.mfc)