zig-yaml icon indicating copy to clipboard operation
zig-yaml copied to clipboard

Why it's encouraged to use `Arena Allocator` for parse?

Open Gnyblast opened this issue 8 months ago • 0 comments

Hi there,

This might be a non-sense question maybe because I'm missing something, but I'm trying to understand deep down so that I won't be doing a programatic mistake in my app with usage of this library.

  1. The parser encourages us to use arena allocator right? Since in the parameter it says arena for parameter name and also in the readme file it demonstrates so.
  2. Well... There might be occasions that this yaml is not long lived, but I'd like to specify my usage which is widely the case in my opinion that uses yaml parsers. My application reads the yaml config of the client and configures itself accordingly, and keeps using these configs during the life-time of the program.
  3. When that's the case, you don't expect to create an arena allocator and keep it un-deinitialized, forever until program dies. Better and more appropiate usage would be using the GPA (DebugAllocator newly) that will be lasting long and be used as a primary memory manager for the app during it's life. At least that's what I'm thinking, but I'm also not 100% sure that's why I'm opening this ticket.

So please enlight me, I know that I still can use a generic allocator to pass it in and parser uses that, but my question is obviously that... is it right to do that? Was there any other blocker so that it's encouraged to use arena? I also don't wanna write deep copy functions, so before deiniting the arena, deep copy it to the actual allocator because that's kind of a redundent implementation and my struct is a bit complex and requires many deep copy for each level etc.

Gnyblast avatar Apr 22 '25 07:04 Gnyblast