zevv / npeg

PEGs for Nim, another take
MIT License
330 stars 22 forks source link

`-d:npegTrace` code allocates a number of closures equal to the number of states #39

Closed Varriount closed 2 years ago

Varriount commented 3 years ago

When npegTrace is enabled, a closure is allocated for each state generated by NPeg. This is due to the fact that doTrace is defined inside genTraceCode. For large grammars, this can cause programs to suddenly crash, due to the program attempting to allocate stack memory for all the closure pointers.

zevv commented 2 years ago

Yeah sorry for that, the tracing implementation is not really optimized for size or performance, as it is not something one would typically run into. I do prefer keeping it as-is because of the simple implementation.

Closing the ticket now as part of spring cleaning, feel free to reopen if needed!