Should we regularly free context.temp_allocator, even if unused?

I noticed two things about context.temp_allocator

  • Core lib procs implicitly allocate in it.
  • It’s by default an Arena allocator.

Does this mean that the user code has to regularly clean it up, even if it is never used in user code? Otherwise, it’s a type of leak.

The idea of the temp allocator is that you release everything allocated with it at the end of the update loop, request handler, etc… using the free_all proc

So, is that a “yes”?

Yes

But it’s a lot simpler than having to track every temp allocation. It’s just a simple arena allocator, so free_all just sets the pointer to the start of the arena and it’s up to you to be sure that you aren’t keeping any references to data in the arena across frame/request/whatever boundaries

1 Like