rs / zerolog

Zero Allocation JSON Logger
MIT License
10.33k stars 564 forks source link

Understanding "Zero Allocation" #652

Closed CaledoniaProject closed 6 months ago

CaledoniaProject commented 6 months ago

Hi there, I'm wondering what "Zero Allocation" means? If you're talking about "No data copy", I'm wondering how it's implemented.

mitar commented 6 months ago

It means that the average amount of allocation on heap is zero, which is expensive because it has to be garbage collected. It still allocates on stack, but allocating and freeing on stack is cheaper.