ВходНаше всё Теги codebook 无线电组件 Поиск Опросы Закон Четверг
28 ноября
356260 Топик полностью
SciFi (21.09.2012 17:26, просмотров: 318) ответил MegaJohn на а что так malloc не любите ?
Ну здрассте! -> http://stackoverflow.com/questions/1725923/how-bad-is-it-to-use-dynamic-datastuctures-on-an-embedded-system
There are a number of reasons not to use malloc (or equivalent) in an embedded system. - As you mentioned, it is important that you do not suddenly find yourself out of memory. - Fragmentation - embedded systems can run for years which can cause a severe waste of memory due to fragmentation. - Not really required. Dynamic memory allocation allows you to reuse the same memory to do different things at different times. Embedded systems tend to do the same thing all the time (except at startup). - Speed. Dynamic memory allocation is either relatively slow (and gets slower as the memory gets fragmented) or is fairly wasteful (e.g. buddy system). - If you are going to use the same dynamic memory for different threads and interrupts then allocation/freeing routines need to perform locking which can cause problems servicing interrupts fast enough. - Dynamic memory allocation makes it very difficult to debug, especially with some of the limited/primitive debug tools available on embedded system. If you statically allocate stuff then you know where stuff is all the time which means it is much easier to inspect the state of something. Best of all - if you do not dynamically allocate memory then you can't get memory leaks.
Ну и ещё одну причину можно приписать: менеджер динамической памяти также требует немного памяти программ.
ส็็็็็็็็็็็็็็็็็็็็็็็็็༼ ຈل͜ຈ༽ส้้้้้้้้้้้้้้้้้้้้้้้