MONGOC_CLEANUP(3)

okay bestie, welcome to the MONGOC_CLEANUP(3) page from libmongoc 🌸 this one is short but lowkey important: it's the end-of-program cleanup vibe check, and the driver really wants you to do it exactly once πŸ’…

✨ SYNOPSIS ✨

          void
          mongoc_cleanup (void);

πŸ’… DESCRIPTION πŸ’…

First things first, bestie: you initialize the MongoDB C Driver by calling mongoc_init() exactly once at the beginning of your program ✨ It's responsible for initializing global state such as process counters, SSL, and threading primitives β€” iconic setup behavior, no cap.

Exception to this is mongoc_log_set_handler(), which should be called before mongoc_init() or some log traces would not use your log handling function. See Custom Log Handlers for a detailed example. Not me warning you about log order 😭

At the end of your program, call mongoc_cleanup() exactly once to release all memory and other resources allocated by the driver 🧚 It's giving cleanup, but make it thorough.

You must not call any other MongoDB C Driver functions after mongoc_cleanup(). Like, none. That's the rule, bestie 🚫

Note that mongoc_init() does not reinitialize the driver after mongoc_cleanup(). So don't treat cleanup like a little reset button β€” it's not, and that's periodt πŸ’€

πŸ‘‘ AUTHOR πŸ‘‘

MongoDB, Inc πŸ‘‘

2009-present, MongoDB, Inc. πŸ’–


okay bye bestie, stay clean and may your resources be released exactly once 🫢 this iconic page is from version 2.5.6, dated Oct 09, 2026, and the manual name is libmongoc 🌈

πŸ“¦ where this page comes from