Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

关于writerbuffer初始化Reserve和Grow的长度

Open
#115 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
30/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
cpp
Domain
performance

Research direction

Start at SerializeImpl and trace how writerbuffer uses Reserve(estimate) and Grow(inc_len), including the constants and length formulas shown in the issue. Measure or inspect the resulting allocations, then document what the values represent and whether the reported memory behavior requires a specific correction.

Written by the indexing model from the issue text.

Description

constexpr size_t kExpectMinifyRatio = 18;
size_t estimate = node_nums * kExpectMinifyRatio + 64;
wb.Reserve(estimate);

inc_len = str_len * 6 + 32 + 3;
wb.Grow(inc_len);
想问一下,SerializeImpl这个函数里,writerbuffer初始化的长度和Grow的长度是以什么作为考量的,代码里的这些数字代表什么含义呢?最近执行代码的时候发现这里的内存分配感觉有些问题,

Dominant language
C++
Stars
976
Forks
128
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from bytedance/sonic-cpp

All issues in bytedance/sonic-cpp

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.