Skip to content

Memory leak: Json::Value cannot be release #1548

Open
@OnlySoaring

Description

@OnlySoaring

Describe the bug
When I use Json:: Reader or Json:: parseFromStream to create Json:: Value, the memory of Json:: Value is not released when the function ends

To Reproduce

int main(int argc, char** argv)
{
  while(true)
  {
    Json::Value root;
    std::ifstream ifs("/opt/user.json");
    Json::Reader reader;
    reader.parse(ifs, root);
    ifs.close();

    std::cout<<"1"<<std::endl;
    break;
  }

  while(true)
  {
    std::cout<<2<<std::endl;
  }
return 0;
}

Expected behavior
My JSON file has 681MB. When the test program printed 1, the program occupied 2.12GB of memory. At the end of "while", Json:: value should be released, but when the test program prints 2, the memory does not decrease. Whether I use Json:: Reader or Json:: parseFromStream, it's the same. This is fatal for multi program projects as it occupies useless memory.

Desktop (please complete the following information):

  • OS: Ubuntu20.04
  • C++ 17

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions