Skip to content

Are these memory leak findings valid? #4031

Answered by gregmarr
farkasdvd asked this question in Q&A
Discussion options

You must be logged in to vote

Yes, the json_value object is contained in struct data and json_value::destroy() is called in data's destructor here:

https://github.com/nlohmann/json/blob/develop/include/nlohmann/json.hpp#L4223

    ~data() noexcept
    {
        m_value.destroy(m_type);
    }

The unique_ptr is used in the create function so that the memory is released if the T constructor throws.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by farkasdvd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants