Memory not released after Remove function.

Hello,
I wish to express my gratitude for OpenCASCADE developers.

I have a question about OpenCASCADE 6.3 usage.
I used OpenCASCADE as follows.

(1) Set AutoActivateSelection OFF.
myAISContext->SetAutoActivateSelection(Standard_False);

(2) Create 3D object.
gp_Pnt point(0.0, 0.0, 0.0);
gp_Dir direction(1.0, 0.0, 0.0);
TopoDS_Shape cone = BRepPrimAPI_MakeCone(gp_Ax2(point, direction), 50.0, 0.0, 50.0);
Handle(AIS_Shape) handle = new AIS_Shape(cone);

(3) Display 3D object with DisplayMode index 1.
myAISContext->SetDisplayMode(handle, 1, Standard_False);
myAISContext->Display(handle, Standard_True);

(4) Delete 3D object.
myAISContext->Remove(handle);

After (4), memory seems to be not released.
I repeated steps (2)-(4) many times, then memory usage was increasing and
finally, memory was insufficient.
Is a wrong usage done?

---------------------------------------------------------
//Test code.
---------------------------------------------------------
void test() {
myAISContext->SetAutoActivateSelection(Standard_False);

for (int j = 0; j gp_Pnt point(0.0, 0.0, 0.0);
gp_Dir direction(1.0, 0.0, 0.0);
TopoDS_Shape cone = BRepPrimAPI_MakeCone(gp_Ax2(point, direction), 50.0, 0.0, 50.0);
Handle(AIS_Shape) handle = new AIS_Shape(cone);

myAISContext->SetDisplayMode(handle, 1, Standard_False);
myAISContext->Display(handle, Standard_True);

myAISContext->Remove(handle);
}
}
---------------------------------------------------------

* If displayed with DisplayMode index 0, memory usage was not increasing.
myAISContext->SetDisplayMode(handle, 0, Standard_False);

* If set AutoActivateSelection ON, memory usage was increasing.
myAISContext->SetAutoActivateSelection(Standard_True);

(My Environment)
- OpenCASCADE 6.3
- Windows XP (SP2) / Visual Studio 2005
(Using Visual C++ 6.0, the same problem happened.)

Yokoyama

Dmitry Khabi's picture

Have you tried to delete AIS_Shape instance?

myAISContext->Remove(handle);
handle=NULL;

yokoyama@adin.co.jp's picture

Thank you for your advice!!

I had tried to delete AIS_Shape instance.

myAISContext->Remove(handle);
handle = NULL;

or

myAISContext->Remove(handle);
handle.Nullify();

But my problem could not be resolved.

Dmitry Khabi's picture

Not at all;)
What is the diffent between
myAISContext->Remove(handle);
and
myAISContext->Clear(handle);
?

yokoyama@adin.co.jp's picture

Thank you for your response. :-)

I have tried two methods.

(1) myAISContext->Remove(handle);
(2) myAISContext->Clear(handle);

But, the difference was not seen.
(Memory usage was not decreased.)

I read the comment in the header file "ais_interactivecontext.hxx",
and two methods seemed to be same.

liao weidong's picture

Hi  Yokoyama

I have the same problem ,have you solved the problem yet?

Greets,

Liao

Kirill Gavrilov's picture

This is a twelve-years-old topic!

If you experience a reproducible memory leak on up-to-date OCCT version (7.5.0), consider reporting an issue on Bugtracker with necessary details.
Check graphic driver updates as well, as displaying a model in 3D viewer involves OpenGL drivers, which may also contain memory usage bugs.