4 ms·
Just don't generate garbage. You shouldn't be using malloc anyway you silly embedded programmer. Half joking, as a C/C++ programmer here.
by greesil 4y ago
Just don't generate garbage. You shouldn't be using malloc anyway you silly embedded programmer.
Half joking, as a C/C++ programmer here.
- SAI_Peregrinus 4y agomalloc() 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.