2 ms·
Do you think your malloc/free (or kmalloc) implementation has no non-deterministic delays? I hate to break it to you, but malloc/free is not magical and O(1).
by rwmj 10y ago
Do you think your malloc/free (or kmalloc) implementation has no non-deterministic delays? I hate to break it to you, but malloc/free is not magical and O(1). It's complex, even reaching into the cache and operating system, and non-deterministic.
- monocasa 10y agoYep, hard real time code tends not to malloc and free for that reason. Most hard real time systems only allow dynamic memory management at system initialization, not at normal runtime.
- Kenji 10y ago>I hate to break it to you, but malloc/free is not magical and O(1). Trust me, I know more about it than I'd like to. I work on embedded software with hard realtime constraints and we had to remove all malloc/free calls from the critical paths. What I don't like is people claiming garbage collection is free. It annoys me to no end. Garbage collection comes at a clear cost and you need to make a cost/benefit analysis. For your average chat application, this is okay. For video games, it might be, but it's probably already noticeable. For anything remotely realtime, forget garbage collection.
- nickpsecurity 10y ago"For anything remotely realtime, forget garbage collection." Or just use real-time, garbage collection if its costs are acceptable: https://news.ycombinator.com/item?id=14108543 https://news.ycombinator.com/item?id=14108543 At least one is deployed in DO-178B-certified systems in industry that require highest confidence and testing. That's as opposite of your implication as possible.