Is there a memory leak?

Open
#1,436 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
38/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp
Domain
backend

Research direction

Start by reproducing the reported growth with the linked Godbolt example, then trace how repeated assignments to YAML::Node manage shared memory. Compare memory use across iterations and identify whether retained allocations come from the node assignment path; done means the behavior is explained and, if confirmed as a leak, a focused regression test demonstrates the fix.

Written by the indexing model from the issue text.

Description

Hi,

I am using yaml-cpp for parsing/emitting YAML because it is very simple and flexible as it comes with many predefined type conversions which can easily be extended.
However, the behaviour of the underlying shared memory management is surprising to say the least: in a simple example as the following, the memory usage will increase out of bounds (several GBytes before the program gets killed).

YAML::Node node;
node["test"] = 42;
for(auto i=0; i<10000000; ++i) {
node["test"] = 42;
}

There is a live repro here: https://godbolt.org/z/4PWezz16r. I first issued an open question on stackoverflow here: https://stackoverflow.com/staging-ground/79939206

While the example is rather artificial, we have cases where we read and override configuration data (YAML) many times, and having such behaviour as described above makes us hesitate to use yaml-cpp.

Thanks for any hints on this. Cheers,
Ralf

Dominant language
C++
Stars
6.1k
Forks
2.2k
Avg merge
22h 2m
Merged PRs (30d)
1

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 jbeder/yaml-cpp

All issues in jbeder/yaml-cpp

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.