Martin Fiala - 2015-10-07

Hello,

I'm using following code to demonstrate the behavior:

void load1MbXmlFile()
{
std::string fileName = "1mb.xml";
TiXmlDocument doc;
doc.LoadFile(fileName.c_str());
}

void load23MbXmlFile()
{
std::string fileName = "23mb.xml";
TiXmlDocument doc;
doc.LoadFile(fileName.c_str());
}

int main()
{
load1MbXmlFile();
load23MbXmlFile();
load1MbXmlFile();
load23MbXmlFile();
}

Checking the mem usage when stepping the program, the mem goes up, but never goes down until the program finishes. I thought, as the TiXmlDocument objects are local to the functions, that it should release all the resources once it is out of scope, but htop reports:
VIRT RES SHR
after 1st load1MbXmlFile()---> 14652 12220 856
after 1st load23MbXmlFile()--> 100M 99944 884
after 2nd load1MbXmlFile()---> 100M 99948 884
after 2nd load23MbXmlFile()--> 124M 121M 884

Why is this happening?
Running the program with valgrind gives "All heap blocks were freed -- no leaks are possible".

Thanks.