Skip to content

WithFields continuously appending fields causes high memory allocation and long GC time #4962

@jackz-jones

Description

@jackz-jones

Describe the bug
Using a shared richlogger object in the project, calling WithFields to print business logs. In high-frequency operation modules, WithFields continuously appends fields, causing high memory allocation and long GC time, which slows down system execution.


使用公共的 richlogger 对象,在项目中调用 WithFields 打印业务日志,在高频操作模块,WithFields 会不停追加 fields 导致内存分配和gc耗时久,系统执行变慢

To Reproduce
Steps to reproduce the behavior, if applicable:

  1. The code is

  2. The error is

    
    

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Environments (please complete the following information):

  • OS: linux
  • go-zero version 1.6.5
  • goctl version 1.6.0

More description
Add any other context about the problem here.

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions