ibireme / yyjson

The fastest JSON library in C
https://ibireme.github.io/yyjson/doc/doxygen/html/
MIT License
2.98k stars 262 forks source link

mem leak #143

Open jackxia123 opened 8 months ago

jackxia123 commented 8 months ago

Describe the bug we found our app is leaked out ,we use heaptrack to catch yyjson file exists leak mem

Your environment

Additional context if you want to know more , i will give you the stack traces logs

ibireme commented 8 months ago

Please share the code or steps to reproduce the issue. If available, providing the stack trace logs would be helpful as well.

tannerdsilva commented 2 weeks ago

I have a backend linux process that has been getting sigkill by the kernel for memory (much to my surprise). This is a repeated issue. As such, I've been prompted to shoehorn my linux process into a signed MacOS binary so that I can profile with the nice tools on that platform.

I came into the profile test fully expecting my binary target to have a leak (as I'm using Unmanaged and a lot of other stuff)....but the verdict is clear, yyjson is the leaker.

Screenshot 2024-06-29 at 9 47 21 PM

See column right, according to my tools and application context, the leak is squarely in this yyjson_mut_write_minify function.

There may be other leaks but this is the one I'm hitting in my application, now on MacOS and Linux.

tannerdsilva commented 2 weeks ago

update: upon further inspection, the leak here was my responsibility. so I have no evidence to contribute towards a memory leak in yyjson.

the yyjson header documentation made it clear how I needed to handle this memory and I failed to stay in line.