View Issue Details

IDProjectCategoryView StatusLast Update
0032616CommunityOCCT:Samplespublic2022-10-19 15:50
Reporterocc_siddhesh_nikam Assigned Tovpozdyayev 
PrioritynormalSeverityjust a question 
Status newResolutionopen 
PlatformWindowsOSWindows 
Product Version7.5.0 
Summary0032616: Samples, MFC - Error on debugging (Standard_MMgrRaw::Free)
DescriptionHello Sir,

I have just started a new project with OCCT 7.5.0.

I have simply added following lines in "Application.cpp" file generated by "MFC":

   # Handle(Aspect_DisplayConnection) aDisplayConnection;
   # myGraphicDriver = new OpenGl_GraphicDriver(aDisplayConnection);

It is working properly.

But when I close the Main Window, the code throws an error by opening a file
<Standard_MMgrRaw.cxx>

   # void Standard_MMgrRaw::Free(Standard_Address theStorage)
   # {
   # free(theStorage);
   # }

Is it a memory leak due to dynamic memory allocation of "Handle" Graphic3d_GraphicDriver?

How to resolve this? Please help.

Thanks.

TagsNo tags attached.
Test case number

Attached Files

  • memory leak error occt 7.5.png (47,927 bytes)
  • release build_error.png (13,296 bytes)
  • OpenGI_GraphicDriver.png (97,132 bytes)
  • V3d_View.png (9,789 bytes)

Activities

kgv

2021-10-12 13:52

developer   ~0104604

Provided information is incomplete.

>I have simply added following lines in "Application.cpp" file generated by "MFC":
> # Handle(Aspect_DisplayConnection) aDisplayConnection;
> # myGraphicDriver = new OpenGl_GraphicDriver(aDisplayConnection);
There is no declaration of myGraphicDriver in quoted code, so I suppose that the sample is much more complicated than "simply added following lines" to a freshly written project.

occ_siddhesh_nikam

2021-10-12 14:25

reporter   ~0104606

Last edited: 2021-10-12 17:17

Thanks for the reply.

In the "Application.h" header file, I have already declared a variable
     # Handle(Graphic3d_GraphicDriver) myGraphicDriver;

It is giving the error.

I never faced this error in older version of OCCT (OCCT 7.2.0).

Please help! Thanks.

occ_siddhesh_nikam

2021-10-14 10:10

reporter   ~0104631

Hello kgv,

As I understood, a "Handle" is a smart_pointer in OCCT with automatic memory deallocation. Is it correct?

I am not getting why the above error is generating?
Is it a bug in OCCT 7.5?

Please guide!

kgv

2021-10-14 11:37

developer   ~0104632

> a "Handle" is a smart_pointer in OCCT with automatic memory deallocation.
Yes.

> I am not getting why the above error is generating?
The problem description is unclear.
I would guess that this might be related to MFC-specific stuff overriding memory allocation routines for debugging purposes.

Are you running Debug/Release application paired with Debug/Release OCCT builds?
Does it happen in both Debug and Release builds?

occ_siddhesh_nikam

2021-10-14 13:54

reporter   ~0104634

Last edited: 2021-10-14 13:59

Hello kgv,

> Are you running Debug/Release application paired with Debug/Release OCCT
builds?
 * I have built OCCT 7.5 with CMake and followed the occt_mfc example:
   "04_Viewer3D."
 * I have set Compiler, Linker and Runtime properties by referring "Viewer3D.sln"

> Does it happen in both Debug and Release builds?
It is throwing an error when I close the window by pressing "X" button in both Release and Debug version.

Screenshot attached: 1) error with "Debug" version (black background).
                     2) error with "Release" version.

Thanks.

occ_siddhesh_nikam

2021-10-14 13:55

reporter  

memory leak error occt 7.5.png (47,927 bytes)

occ_siddhesh_nikam

2021-10-14 13:57

reporter  

release build_error.png (13,296 bytes)

occ_siddhesh_nikam

2021-10-16 10:26

reporter  

OpenGI_GraphicDriver.png (97,132 bytes)

occ_siddhesh_nikam

2021-10-16 10:35

reporter   ~0104668

Dear kgv,

I am unable to find "why I am getting Graphic_Driver related run-time error."

What is wrong in the following lines?
     # Handle(Graphic3d_GraphicDriver) myGraphicDriver;
     # Handle(Aspect_DisplayConnection) aDisplayConnection;
     # myGraphicDriver = new OpenGl_GraphicDriver(aDisplayConnection);

Is it related to occt-project properties in Visual Studio 2019? or what else?

I request you, please kindly suggest some ways to overcome this problem.

Thanks.

kgv

2021-10-16 11:38

developer   ~0104673

Last edited: 2021-10-16 11:39

> What is wrong in the following lines?
There is nothing wrong with these particular lines - it is a usual allocation of an object, that could be seen in OCCT samples.
Have you tried building samples coming with OCCT - do they crash in your environment?
Normally, Graphic3d_GraphicDriver instance is not stored as a class field at GUI level - there is no point in it, as it is stored inside created V3d_Viewer;
moreover, many applications create graphic driver as a singleton.

> I request you, please kindly suggest some ways to overcome this problem.
This bugtracker is focused on bug reports.
You might get a better help from community on user forums or using OCC support services.
https://dev.opencascade.org/forums

occ_siddhesh_nikam

2021-10-16 13:58

reporter   ~0104690

> Have you tried building samples coming with OCCT - do they crash in your environment?
Yes, I have tried OCCT samples. All are working without error under same environment.

Thanks for the reply.

occ_siddhesh_nikam

2021-10-18 11:26

reporter   ~0104695

Dear kgv,

The problem has solved now.
 
Actually, I had selected an option "USE_GLES2 instead of OpenGL" in "CMake" while building OCCT. I rebuilt OCCT by unchecking above option in "CMake" and it worked.

As suggested by you before, I have updated from version 7.2 to 7.5 because,
in version 7.2, multiple "V3d_View" windows (created in a dialog) does not appear simultaneously. It is giving very weird behavior while opening the dialog box.
(**Please see "Issue ID: 0032532" which is currently unresolved.)

Also, by adding a line:
      # m_hView->SetImmediateUpdate(Standard_False);
all "V3d_View" windows disappear.

I think, "V3d_View" should avoid the automatic implicit window redraw.

(with "GLES" option, "V3d_View" multiple windows appear simultaneously; but it gives memory leak error "Standard_MMgrRaw::Free" on runtime.)

Thanks.

kgv

2021-10-18 12:27

developer   ~0104701

> (with "GLES" option, "V3d_View" multiple windows appear simultaneously; but it gives memory leak error "Standard_MMgrRaw::Free" on runtime.)
Why do you call it "memory leak"? I don't see any leaks in your messages, just some memory issues.

occ_siddhesh_nikam

2021-10-19 17:36

reporter   ~0104747

Dear kgv,

> Why do you call it "memory leak"?
Thanks for correcting me.

It will be very helpful if you could little bit explain,
 * why multiple "V3d_View" windows appear simultaneously with "GLES" option?
 * why not it is happening with "OpenGl" option?

Also, by adding a line/code
    # m_hView->SetImmediateUpdate(Standard_False);
all "V3d_View" windows disappear.

Thanks.

(Here onwards I will not ask any query here except bugs.)

kgv

2021-10-20 11:42

developer   ~0104758

Last edited: 2021-10-20 11:43

> * why multiple "V3d_View" windows appear simultaneously with "GLES" option?
Angle implementation of OpenGL ES on top of Direct3D is quite specific and has side effects - it doesn't work transparently and might require adaptation at application level.
So far, I never built MFC samples with Angle library, so I don't know if this combination works or not.

Note that within OCCT 7.6.0 the GLES option in OCCT configuration will enable building of a dedicated library TKOpenGles (depending on GLES) in addition to TKOpenGl (depending on a desktop OpenGL).
There are small practical reasons using limited OpenGL ES on desktop systems - OpenGL is certainly a preferred choice.

> Also, by adding a line/code
> # m_hView->SetImmediateUpdate(Standard_False);
>all "V3d_View" windows disappear.
I don't quite understand - this line is present in standard MFC samples (OCC_BaseView::OnInitialUpdate()).
Do these sample work incorrectly, or you refer to SetImmediateUpdate() only in context of GLES option?

occ_siddhesh_nikam

2021-10-21 11:43

reporter   ~0104776

Hello kgv,

I have created three separate "V3d_View" windows (say window_1, window_2 and window_3) in a single MFC dialog. I have used MFC "static control" as a parent.

When I open a dialog, not all three windows appear at once. Instead of this, window_1 appears 1st, then window_2, then window_3.
It is looking very weird visually.

To avoid this, as per our previous discussion in an Issue No. "0032532", I called "V3d_View::SetImmediateUpdate(Standard_False);"
but instead of solving the above problem, it deactivates "V3d_View" and dialog only shows three "static controls."
(This is shown in Figure 1 and 2)

There is no any MFC sample which contains multiple (more than 1) "V3d_View" windows in a single dialog.

Thanks.

occ_siddhesh_nikam

2021-10-21 11:43

reporter  

V3d_View.png (9,789 bytes)

kgv

2021-10-21 12:21

developer   ~0104780

> There is no any MFC sample which contains multiple
Consider attaching a minimal sample-reproducer to the bug or sharing it on GitHub.

occ_siddhesh_nikam

2021-10-22 18:00

reporter   ~0104801

Hello kgv,

I have created a sample dialog in MFC with three "V3d_View" windows.
I have uploaded the sample files on a GitHub.
Here is the link...
   https://github.com/nikamsv/V3d_View_Dlg.git

(Kindly note that, I am using GitHub first time. If you notice any mistake, please let me know.)

Thank you.

Issue History

Date Modified Username Field Change
2021-10-12 13:37 occ_siddhesh_nikam New Issue
2021-10-12 13:37 occ_siddhesh_nikam Assigned To => kgv
2021-10-12 13:50 kgv Severity minor => just a question
2021-10-12 13:52 kgv Note Added: 0104604
2021-10-12 14:25 occ_siddhesh_nikam Note Added: 0104606
2021-10-12 14:26 occ_siddhesh_nikam Note Edited: 0104606
2021-10-12 14:28 occ_siddhesh_nikam Note Edited: 0104606
2021-10-12 17:17 occ_siddhesh_nikam Note Edited: 0104606
2021-10-14 10:10 occ_siddhesh_nikam Note Added: 0104631
2021-10-14 11:37 kgv Note Added: 0104632
2021-10-14 13:54 occ_siddhesh_nikam Note Added: 0104634
2021-10-14 13:55 occ_siddhesh_nikam File Added: memory leak error occt 7.5.png
2021-10-14 13:57 occ_siddhesh_nikam File Added: release build_error.png
2021-10-14 13:59 occ_siddhesh_nikam Note Edited: 0104634
2021-10-16 10:26 occ_siddhesh_nikam File Added: OpenGI_GraphicDriver.png
2021-10-16 10:35 occ_siddhesh_nikam Note Added: 0104668
2021-10-16 11:38 kgv Note Added: 0104673
2021-10-16 11:38 kgv Note Edited: 0104673
2021-10-16 11:39 kgv Note Edited: 0104673
2021-10-16 13:58 occ_siddhesh_nikam Note Added: 0104690
2021-10-18 11:26 occ_siddhesh_nikam Note Added: 0104695
2021-10-18 12:27 kgv Note Added: 0104701
2021-10-18 12:28 kgv Category OCCT:Application Framework => OCCT:Samples
2021-10-18 12:28 kgv Summary Erro on debugging (Standard_MMgrRaw::Free) => Samples, MFC - Error on debugging (Standard_MMgrRaw::Free)
2021-10-19 17:36 occ_siddhesh_nikam Note Added: 0104747
2021-10-20 11:42 kgv Note Added: 0104758
2021-10-20 11:42 kgv Note Edited: 0104758
2021-10-20 11:43 kgv Note Edited: 0104758
2021-10-21 11:43 occ_siddhesh_nikam Note Added: 0104776
2021-10-21 11:43 occ_siddhesh_nikam File Added: V3d_View.png
2021-10-21 12:21 kgv Note Added: 0104780
2021-10-22 18:00 occ_siddhesh_nikam Note Added: 0104801
2022-10-19 15:50 smoskvin Assigned To kgv => vpozdyayev