This code eats up to 1.5GB of memory and doesn't release it.
Why ? I'm expecting the memory to be freed after the call to the bigone function.
How to fix this ?
#include <iostream>
#include <jsoncpp/json/json.h>
#include <jsoncpp/json/value.h>
typedef unsigned char utiny;
void watchmem() {
char k;
std::cout << "watch memory consumption then press a key ";
std::cin >> k;
}
void bigone() {
Json::Value conf = Json::arrayValue;
for(utiny i = 0; i < 255; i++) {
for(utiny j = 0; j < 255; j++) {
for(utiny k = 0; k < 255; k++) {
conf[i][j][k] = 0;
}
}
}
}
int main(int argc, char **argv) {
bigone();
watchmem();
}
build:
g++ -std=c++11 -o chkmem chkmem.cpp -ljsoncpp && ./chkmem