Wed, 09/06/2023 - 19:57
Hello,
I am encountering memory leak in the following function as pointed out by valgrind:
Handle(TDocStd_Document) ReadStep(std::string filename){ STEPCAFControl_Reader Reader; // Create XDE document. Handle(XCAFApp_Application) app = XCAFApp_Application::GetApplication(); BinXCAFDrivers::DefineFormat(app); Handle(TDocStd_Document) doc; app->NewDocument("BinXCAF", doc); // Read CAD and associated data from file IFSelect_ReturnStatus outcome = Reader.ReadFile(filename.c_str()); // if ( outcome != IFSelect_RetDone ) { app->Close(doc); return nullptr; } if ( !Reader.Transfer(doc) ) { app->Close(doc); return nullptr; } return doc; }
Am I doing something wrong? I am a beginner to C++. Any help is greatly appreciated.
Best Regards
Kaiwen
Wed, 09/06/2023 - 20:05
Hello,
How you clarify that it is a leak? Could you send a valgrid report?
Best regards, Dmitrii.
Wed, 09/06/2023 - 20:22
Hello,
I have attached the valgrind output.
Best Regards
Kaiwen
Wed, 09/06/2023 - 20:44
Unfortunatelly you using occt 7.4 (4 year old release).
Probably you can't impact on it. It is internal problem. I will check the same code on 7.8.0 with valgrind.
Best regards, Dmitrii.
Wed, 09/06/2023 - 20:46
Thank you for your effort and fast answer.
I am looking forward to your response.
Best Regards
Kaiwen
Thu, 09/07/2023 - 21:58
Hello Dmitrii,
have you found out anything?
Also if I want to upgrade my OCCT version how do I go about it?
I have installed the 7.4 version via cmake on my system. Is there a "make uninstall" option?
Best Regards
Kaiwen
Fri, 09/08/2023 - 16:19
I will plan to check it a little later. But probably it is resolved on last version.
Unistall is not possible in native cmake-make env.
Best regards, Dmitrii.
Thu, 09/07/2023 - 22:36
At least one related issue #0031075 has been fixed in OCCT 7.5. So it makes sense to check later releases. Note that STEP translator uses some global objects, which are not automatically released, but reused on next translations.
Fri, 09/08/2023 - 20:06
Hello,
I have updated OCCT to version 7.7 (which is the latest release as I can see), but unfortunately the problem still persists.
I have attached a valgrind report using version 7.7
Also, I noticed the memory lost depends heavily on the STEP file read using STEPControl_Reader
Best Regards
Kaiwen
Fri, 09/08/2023 - 22:21
Valhrind is great for deep checks, but could you provide a real-world use case with repetitive STEP imports resulting in memory leaks and amount of them? (Kilobytes, megabytes?). Does memory leak noticable for entire application workflow?
Fri, 09/08/2023 - 23:29
The report describes issues with buffered global static variables allocation in SControl_Controller::Customise, STEPEdit_EditContext, Interface_Staticand similar that is not a leaks. But just an artifacts of old DE way. We planned to update this, but it is not a leak. This "leak" will not so impact on more then one read process.
But thank you. We will take more attention on this.
Best regards, Dmitrii.