4 ms·
> memory allocation takes a ton of time Depends how you define "a ton of time". Good general purpose memory allocation algorithms, like the TLSF algorithm [1],
by hgs3 2y ago
> memory allocation takes a ton of time
Depends how you define "a ton of time". Good general purpose memory allocation algorithms, like the TLSF algorithm [1], guarantee a O(1) bounded response time suitable for real-time use. To your example however, if someone introduces extra computation into math-heavy hot-looping code, then that is just sloppy development as their adding extra computation. That extra computation being memory allocation is tangential.
[1] https://www.researchgate.net/publication/4080369_TLSF_A_new_dynamic_memory_allocator_for_real-time_systems https://www.researchgate.net/publication/4080369_TLSF_A_new_...
- refulgentis 2y agoIn this context, it's not tangential, it's core. I described observing programmers I've worked with struggled to understand that memory allocation could *ever* have a significant computation cost.