Memory not released properly when using STEPCAFControl_Reader in Docker (ubuntu:build-24.04)

Hello,
I have a rather simple task of reading STEP file and sending it to another application (console application, cmake). The code was written using existing examples and works fine.
With Windows there are no errors, all memory is released and VS profiler and ASAN shows no leaks. But when i build Docker and look at resources i see that after loading, transefering and processing is complete, the thread that was doing the job is finished, most of the memory is not released. I checked with free, ps and top (see attachments. Actual file size is ~142 Mb)
I tried using tips and methods shown here https://dev.opencascade.org/content/memory-leak-when-using-stepcafcontrolreader
but to no effect.
The code for loading step file:

(_doc and tools are class members

 
Handle(XCAFDoc_ShapeTool) _shapeTool;
Handle(XCAFDoc_ColorTool) _colorTool;
Handle(TDocStd_Document)  _doc;

)

    Handle(XCAFApp_Application) app = XCAFApp_Application::GetApplication();
    app->NewDocument("MDTV-XCAF", _doc);
    STEPCAFControl_Reader reader;
    IFSelect_ReturnStatus status = reader.ReadFile(_savePath.c_str());
    if (status != IFSelect_RetDone) {
        std::cerr << "[ERROR] Error reading STEP-file: " << _savePath << std::endl;
        return R"({"error": "Error reading STEP-file"})";
    }

    if (!reader.Transfer(_doc)) {
        std::cerr << "[ERROR] Error in transferring data." << std::endl;
        return R"({"error": "Error in transferring data"})";
    }
    _shapeTool = XCAFDoc_DocumentTool::ShapeTool(_doc->Main());
    _colorTool = XCAFDoc_DocumentTool::ColorTool(_doc->Main());

    if (_shapeTool.IsNull() || _colorTool.IsNull()) {
        std::cerr << "[ERROR] Could not acquire XDE tools." << std::endl;
        return R"({"error": "Could not acquire XDE tools"})";
    }
    reader.ChangeReader().ClearShapes();
    reader.Reader().WS()->ClearData(1);
    reader.Reader().WS()->ClearContext();
    Handle(XSControl_WorkSession) aWS = reader.Reader().WS();
    if (Handle(XSControl_TransferReader) transferReader = aWS->TransferReader()) {
        if (Handle(Transfer_TransientProcess) mapReader = transferReader->TransientProcess()) {
            mapReader->Clear();
        }
        transferReader->Clear(-1);
    }

_doc is cleared later with

 
        Handle(XCAFApp_Application) app = XCAFApp_Application::GetApplication();
        if (!_doc.IsNull()) {
            if (_doc->HasOpenCommand())
            {
                _doc->AbortCommand();
            }

            _doc->Main().Root().ForgetAllAttributes(Standard_True);
            app->Close(_doc);
            _doc.Nullify();
        }

Noticed one thing though: if i don't use reader.Transfer(_doc) bigger part of memory is released

Attachments: 
Dmitrii Pasukhin's picture

Hello.

Please share the OCCT version.

There are a change that something keep objects alive, need to validate the OCC version.

Without reader.Transfer(_doc) shapes are not created, so, no memory was used.

Best regards, Dmitrii.

Alexander Petrov's picture

Hello, OCCT Version: 7.9.0 by OCC_VERSION_COMPLETE

Dmitrii Pasukhin's picture

Oke, then could you please create an issue on GitHub? https://github.com/Open-Cascade-SAS/OCCT/issues/new/choose

If it is possible, please create a single method which helps us to reproduce the error (at least using profiler). The test will be done by GTest (single singleton function).

Best regards, Dmitrii,

Alexander Petrov's picture

Sure, will do.

Alexander Petrov's picture