Time and memory consumption for occt operation

In Gmsh I create one point and apply a translate operation 10000 times.

It takes 15 GB memory and 20 seconds. The Gmsh-5-lines script is attached (extension is changed from .geo to .txt). Gmsh 4.13.1 (OCC 7.7.2), Windows 10.

Would you clarify, please, is it a problem of OpenCascade or Gmsh?

Thank you in advance.

Attachments: 
Dmitrii Pasukhin's picture

Hello, could you please somehow incorporate the code by python or draw or c++?

The issue is strangle and probable related to bug with scope and life time. Probably the translated variable exist on dynamic memory and creates more and more during the loop. And free only after loop breaks.

But that should be not on OCCT Side, on c++ it is a challenge to create bug like that.

Best regards, Dmitrii.

Michael Ermakov's picture

Hello, Dmitrii!

Idea to run C++ code was fruitful. Thanks.
I ran code in VS and got Stack Overflow error. An increase of stack size allows to make more number of translate operations (with huge memory consumption). Will prepare debug library of Gmsh and will trace workflow.

Thank you,
Michael.

Michael Ermakov's picture

Thank you, Dmitrii!

I wrote two small test codes in c++: one uses c-kind functions, other one uses c++-kind functions. Both tests produces the same behaviour. Which, however, is a bit different from previous gmsh's script. But these tests also demonstrate rather large memory consumption and fail silently. Test codes names are occ-c.cpp and occ-cpp.cpp. Also there are two similar tests geo-c and geo-cpp which differ only by using gmsh's built-in kernel. Gmsh functions work without remarks in this test.
The text files are attached to the comment.
All directory with libraries and executables could be downloaded from here: https://disk.yandex.ru/d/GmW0OcwMwMLeZw

Best regards, Michael.

Attachments: 
gkv311 n's picture

Michael,

I wrote two small test codes in c++: one uses c-kind functions, other one uses c++-kind functions. Both tests produces the same behaviour. Which, however, is a bit different from previous gmsh's script.

This forum is about OCCT - most users have no idea how these gmsh calls are translated to OCCT. I guess you better post your question on GMSH forum first, and maybe then roll-back with more OCCT-related scenario.

And please share code samples directly on the forum rather than through some external service.

#include <gmsh.h>
#include <stdio.h>

int main(int argc, char **argv) 
{

  gmsh::initialize();

  gmsh::model::add("occ");

  gmsh::fltk::initialize();

  gmsh::model::occ::addPoint(0.0, 0.0, 0.0, 0.01, 1);

  gmsh::model::occ::synchronize();

  const int n=10000;
  for (int i=1;i <= n; i++) {

      gmsh::model::occ::translate({{0,1}}, 0.001, 0.0, 0.0);

      if (i == n) {
        printf("i = %d\n", i);
      }

  }

  gmsh::model::occ::synchronize();
  printf("finished");

  gmsh::fltk::run();
  gmsh::finalize();

  return 0;
}