bytedance / sonic

A blazingly fast JSON serializing & deserializing library
Apache License 2.0
6.59k stars 327 forks source link

frozenconfig.Unmarshal consumes a large amount of memory. #612

Closed Lambert-Sea closed 3 months ago

Lambert-Sea commented 3 months ago

image

As the project runs, Sonic processes an increasing number of conversions between strings and structs. With this, the frozenconfig.Unmarshal method gradually consumes more memory, sometimes suddenly occupying over 80% of the memory. Restarting the service is necessary to release this memory, but the problem reoccurs after a period of time.

What could be the cause of this issue, and how can it be resolved?

AsterDY commented 3 months ago

Try CopyString. If not work, it must be your logic cause (ex: goroutine leak)

Lambert-Sea commented 3 months ago

Try CopyString. If not work, it must be your logic cause (ex: goroutine leak)

Thank for your help.

Could you explain why this will happen? so that I can understand this sonic well.

AsterDY commented 3 months ago

https://github.com/bytedance/sonic?tab=readme-ov-file#copy-string Have you read this ?