Gmsh increases memory when generate(2) C++ API is used repeatedly
I found that C++ API generate(2) slightly increases memory usage but continuously when is used repeatedly. The memory increases for 2000 calls of API generate(2) from 168.9MB (Virt) and 67.4MB (Res) to 175.0MB (Virt) and 73.1MB (Res). This is a problem when the code generates mesh contentiously and it is working for days. For a couple of days memory grows up to ~4GB. When such a code has to work for weeks or months, the memory growing will make code unusable.
The memory increases when:
- Using only C++ API generate(2), without initialize and finalize every time:
for(int Iter = 0; Iter < 1000000; Iter++) { gmsh::model::mesh::generate(2); }
- With initialize and finalize:
for(int Iter = 0; Iter < 1000000; Iter++) { gmsh::initialize(); //Some code ...
gmsh::model::mesh::generate(2);
//Other code ...
gmsh::finalize();
}
- Using clear:
gmsh::initialize();
for(int Iter = 0; Iter < 1000000; Iter++) { gmsh::clear(); //Some code ...
gmsh::model::mesh::generate(2);
//Other code ...
}
gmsh::finalize();
I used example gmsh/demos/api/t1.cpp to demonstrate the issue. The examples were tested on two versions of gmsh: 3.0.7 and 4.0.6. Both versions were build from source on Debian 8.11 with kernel 3.16.59-1.
Best Regards,
Kiril Shterev