3 ms·
malloc() isn't the issue, free() is. Allocate at init, never free, and you'll still have deterministic behavior and no heap fragmentation!* * Unless you run ou
by SAI_Peregrinus 4y ago
malloc() isn't the issue, free() is. Allocate at init, never free, and you'll still have deterministic behavior and no heap fragmentation!*
* Unless you run out of memory, of course. Then you have issues.
- tempodox 4y agomalloc() on an embedded platform can still present pitfalls. This article explains why: https://mcuoneclipse.com/2022/11/06/how-to-make-sure-no-dynamic-memory-is-used/ https://mcuoneclipse.com/2022/11/06/how-to-make-sure-no-dyna...
- SAI_Peregrinus 4y agoYes, you can still run out of memory. But you can't get a fragmented heap if you never free(). And if you allocate only at init, not during the normal operation stage, you can't run out of memory if you manage to start up successfully.