logoalt Hacker News

mrkeentoday at 7:49 PM2 repliesview on HN

> TigerStyle: All memory must be statically allocated at startup. No memory may be dynamically allocated (or freed and reallocated) after initialization. This avoids unpredictable behavior that can significantly affect performance, and avoids use-after-free.

Maybe maintaining an array of NULL-orders satisfies the letter of the "no dynamic allocation" law, but I'm not convinced it satisfies the spirit.

Haven't you just written a buffer of NULL-orders, which you proceed to loan out to callers (i.e. "allocate" and "reallocate"?).

Someone else's battle-hardened allocator might be slow or buggy, so you write your own as part of the business logic implementation?


Replies

nickmonadtoday at 9:42 PM

TigerStyle is strictly concerned about dynamic allocation from the perspective of the OS.

Once you have that pool of "objects" that can be recycled throughout the lifetime of the program, you have a guarantee that actual allocation can only be interpreted in a specific way, i.e. all objects have the same size, alignment, etc so you don't have nearly the same level of concern or detail of implementation as an actual allocator in the common understanding of the word. A simple free-list gets you pretty far.

nwjsmithtoday at 8:58 PM

It’s (mostly) not about performance, it’s about minimizing failure. Static memory allocation makes you OOM-proof.

show 1 reply