Re: Policy on rebooting?
From: D. Zimmerman (7UPdzimmerman_at_stny.rr.com)
Date: 10/08/04
- Next message: CBFalconer: "Re: Sanity check: 8k enough flash for small project"
- Previous message: Mike Turco: "Re: Wireless positioning systems"
- In reply to: Michael N. Moran: "Re: Policy on rebooting?"
- Next in thread: Michael N. Moran: "Re: Policy on rebooting?"
- Reply: Michael N. Moran: "Re: Policy on rebooting?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 08 Oct 2004 03:07:24 GMT
Michael N. Moran wrote:
> 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.
>
Actually, it does prevent the problem. The reason is that
the RTOS won't take (for example) a 256 byte space and
re-allocate it in smaller chunks, then turn around and try
to make a 256 byte allocation out of a 128 byte and two 64
byte blocks. Basically there is a memory pool.
The downside is what you alluded to in that it is not as
memory efficient. For example, a structure that needs 200
bytes will get a 256 byte allocation. Life is not perfect.
Dennis,
-- If sending a reply you will need to remove "7UP".
- Next message: CBFalconer: "Re: Sanity check: 8k enough flash for small project"
- Previous message: Mike Turco: "Re: Wireless positioning systems"
- In reply to: Michael N. Moran: "Re: Policy on rebooting?"
- Next in thread: Michael N. Moran: "Re: Policy on rebooting?"
- Reply: Michael N. Moran: "Re: Policy on rebooting?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|