BSON_VALGRIND(3)
π NAME π
bson_valgrind β the way you use Valgrind to check for BSON data leaks, bestie π΅οΈβοΈβ¨
okay so here's the tea. A stack-allocated bson_t comes with a lil internal buffer of its own π β it only heap-allocates extra storage when it actually needs to, and that depends on how big its data is. Which means... if you forget to call bson_destroy() on a stack-allocated bson_t, it might leak. Or it might not. π And valgrind might catch it. Or it might not. It's giving chaos, honestly.
So to catch all the potential BSON data leaks in your code, you gotta configure the BSON_MEMCHECK flag like this:
cmake -DCMAKE_C_FLAGS="-DBSON_MEMCHECK -g" .
With this flag set, literally every single bson_t mallocs at least one byte π₯ (yes, even the tiny ones). So then you run your program's unittests with valgrind and verify that all your bson_t structs got destroyed. No stragglers. No survivors. Periodt. π
And one more thing bestie β set the environment variable MONGOC_TEST_VALGRIND to on so you skip the timing-dependent tests that are known to fail with valgrind. Those tests are not the vibe under valgrind, trust. π«Ά
β¨ AUTHOR β¨
MongoDB, Inc π
πΈ COPYRIGHT πΈ
2017-present, MongoDB, Inc
and that's the whole page, my love π this was libbson version 1.23.1, dated Apr 27, 2026 β go forth and destroy your bson_ts, mwah πβ¨
π¦ where this page comes from
- debian bookworm: libbson-doc 1.23.1-1+deb12u3 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms