Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

>You can predict the time that malloc(3) and free(3) take to run?

The correct answer would be: depends on the concrete implementation. There are implementations with real-time guarantees.

However, assuming standard desktop OS malloc()/free() the answer is: No. These functions can execute very quickly.. or very slowly, depending on their current internal state. But you can control when they get called, which can be an important difference.

>The point you mention is only valid when using entirely static memory, which is a very rare case in real C code (only really used in a few small embedded codebases).

Depends on what you mean by "entirely static memory". No malloc() calls at all? Yes, that is rare and pretty much limited to the embedded realm I think. Memory pools however are very common in performance critical code.



You speak sense. I tend to use apr pools all the time in critical sections.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: