[HN Gopher] Mistakes and cool things to do with arena allocators
       ___________________________________________________________________
        
       Mistakes and cool things to do with arena allocators
        
       Author : skeptrune
       Score  : 44 points
       Date   : 2025-04-10 17:08 UTC (3 days ago)
        
 (HTM) web link (zylinski.se)
 (TXT) w3m dump (zylinski.se)
        
       | o11c wrote:
       | > You can only deallocate everything in the arena, not individual
       | parts of it.
       | 
       | Untrue; this excludes the middle. GNU Obstack is a widely-used
       | arena allocator with a "free everything allocated after this
       | point" operation, among others.
        
         | tonyedgecombe wrote:
         | PostScript does something similar with its save and restore
         | operators.
        
         | grandempire wrote:
         | This is arguing about the definition of an Arena.
         | 
         | It's like if I say a stack only has push and pop, and you tell
         | me you can search though and find another element.
        
         | cogman10 wrote:
         | It'll depend on the allocator. Generally speaking, the better
         | an allocator is at minimizing fragmentation, the slower it's
         | going to be with new allocations.
         | 
         | That's why bump allocators are wicked fast, but make the trade-
         | off the article mentions.
        
       | codr7 wrote:
       | I like composable single feature allocators, a free list is just
       | another kind of allocator that may be plugged in at any point.
       | 
       | https://github.com/codr7/hacktical-c/tree/main/malloc1
       | 
       | https://github.com/codr7/hacktical-c/tree/main/malloc2
        
       ___________________________________________________________________
       (page generated 2025-04-13 23:00 UTC)