logoalt Hacker News

actionfromafar01/23/20250 repliesview on HN

A pattern in some embedded programming is to have an "arena" (just a bunch of pre-allocated memory) and then allow "malloc" (really super simple malloc) from that. But "free" is a no-op and does nothing. (It leaks all memory.) Then you just release the whole arena when you are done. You just reason about and/or test your code until it runs with a given arena size and call it a day. This way you can run "legacy" code written with allocations in mind, but the allocation is super fast with computable upper bounds on how long it takes worst case.

Super crude but useful sometimes.