mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
0031120: Memory leak in BRepOffsetAPI_MakeOffset
Add destructor of MAT2d_Mat2d - full removal of edges and bisectors.
This commit is contained in:
parent
8bfae263c1
commit
23c2ae55c7
@ -36,9 +36,10 @@ class MAT_ListOfBisector : public Standard_Transient
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
Standard_EXPORT MAT_ListOfBisector();
|
Standard_EXPORT MAT_ListOfBisector();
|
||||||
|
|
||||||
|
Standard_EXPORT ~MAT_ListOfBisector();
|
||||||
|
|
||||||
Standard_EXPORT void First();
|
Standard_EXPORT void First();
|
||||||
|
|
||||||
Standard_EXPORT void Last();
|
Standard_EXPORT void Last();
|
||||||
|
@ -36,8 +36,9 @@ class MAT_ListOfEdge : public Standard_Transient
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
Standard_EXPORT MAT_ListOfEdge();
|
Standard_EXPORT MAT_ListOfEdge();
|
||||||
|
|
||||||
|
Standard_EXPORT ~MAT_ListOfEdge();
|
||||||
|
|
||||||
Standard_EXPORT void First();
|
Standard_EXPORT void First();
|
||||||
|
|
||||||
|
@ -197,22 +197,25 @@ void MAT_TList::Unlink()
|
|||||||
Standard_Boolean nextisnull = thecurrentnode->Next().IsNull();
|
Standard_Boolean nextisnull = thecurrentnode->Next().IsNull();
|
||||||
|
|
||||||
if(thecurrentindex)
|
if(thecurrentindex)
|
||||||
|
{
|
||||||
|
if(!nextisnull)
|
||||||
{
|
{
|
||||||
if(!nextisnull && !previousisnull)
|
thecurrentnode->Next()->Previous(thecurrentnode->Previous());
|
||||||
{
|
|
||||||
thecurrentnode->Next()->Previous(thecurrentnode->Previous());
|
|
||||||
thecurrentnode->Previous()->Next(thecurrentnode->Next());
|
|
||||||
}
|
|
||||||
|
|
||||||
if(thecurrentindex == 1)
|
|
||||||
{
|
|
||||||
thefirstnode = thecurrentnode->Next();
|
|
||||||
}
|
|
||||||
else if(thecurrentindex == thenumberofitems)
|
|
||||||
{
|
|
||||||
thelastnode = thecurrentnode->Previous();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (!previousisnull)
|
||||||
|
{
|
||||||
|
thecurrentnode->Previous()->Next(thecurrentnode->Next());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(thecurrentindex == 1)
|
||||||
|
{
|
||||||
|
thefirstnode = thecurrentnode->Next();
|
||||||
|
}
|
||||||
|
else if(thecurrentindex == thenumberofitems)
|
||||||
|
{
|
||||||
|
thelastnode = thecurrentnode->Previous();
|
||||||
|
}
|
||||||
|
}
|
||||||
thenumberofitems--;
|
thenumberofitems--;
|
||||||
thecurrentindex--;
|
thecurrentindex--;
|
||||||
}
|
}
|
||||||
@ -382,3 +385,25 @@ void MAT_TList::Dump(const Standard_Integer ashift,
|
|||||||
{
|
{
|
||||||
for(First(); More(); Next()) Current()->Dump(ashift,alevel);
|
for(First(); More(); Next()) Current()->Dump(ashift,alevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : ~MAT_TList
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
MAT_TList::~MAT_TList()
|
||||||
|
{
|
||||||
|
Handle(MAT_TListNode) aNode = thefirstnode;
|
||||||
|
while (!aNode.IsNull())
|
||||||
|
{
|
||||||
|
Handle(MAT_TListNode) aNext = aNode->Next();
|
||||||
|
aNode->Next (NULL);
|
||||||
|
aNode->Previous (NULL);
|
||||||
|
aNode = aNext;
|
||||||
|
}
|
||||||
|
thecurrentnode.Nullify();
|
||||||
|
thefirstnode.Nullify();
|
||||||
|
thelastnode.Nullify();
|
||||||
|
thecurrentindex = 0;
|
||||||
|
thenumberofitems = 0;
|
||||||
|
}
|
||||||
|
@ -183,6 +183,7 @@ void MAT2d_Mat2d::CreateMatOpen(MAT2d_Tool2d& atool)
|
|||||||
// du contour.
|
// du contour.
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
theedgelist = new MAT_ListOfEdge();
|
theedgelist = new MAT_ListOfEdge();
|
||||||
|
RemovedEdgesList = new MAT_ListOfEdge();
|
||||||
|
|
||||||
for(i=0; i<noofedges; i++) {
|
for(i=0; i<noofedges; i++) {
|
||||||
edge = new MAT_Edge();
|
edge = new MAT_Edge();
|
||||||
@ -401,7 +402,8 @@ void MAT2d_Mat2d::CreateMatOpen(MAT2d_Tool2d& atool)
|
|||||||
previousedge = currentedge;
|
previousedge = currentedge;
|
||||||
currentbisectorlist->Next();
|
currentbisectorlist->Next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RemovedEdgesList->BackAdd(theedgelist->Current());
|
||||||
theedgelist->Unlink();
|
theedgelist->Unlink();
|
||||||
|
|
||||||
//-----------------------------------------------------------
|
//-----------------------------------------------------------
|
||||||
@ -623,6 +625,7 @@ void MAT2d_Mat2d::CreateMatOpen(MAT2d_Tool2d& atool)
|
|||||||
->FirstBisector());
|
->FirstBisector());
|
||||||
|
|
||||||
for(j=0; j<noofarea(i); j++) {
|
for(j=0; j<noofarea(i); j++) {
|
||||||
|
RemovedEdgesList->BackAdd(theedgelist->Current());
|
||||||
theedgelist->Unlink();
|
theedgelist->Unlink();
|
||||||
theedgelist->Next();
|
theedgelist->Next();
|
||||||
shift++;
|
shift++;
|
||||||
@ -851,6 +854,7 @@ void MAT2d_Mat2d::CreateMat(MAT2d_Tool2d& atool)
|
|||||||
// du contour.
|
// du contour.
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
theedgelist = new MAT_ListOfEdge();
|
theedgelist = new MAT_ListOfEdge();
|
||||||
|
RemovedEdgesList = new MAT_ListOfEdge();
|
||||||
|
|
||||||
for(i=0; i<noofedges; i++) {
|
for(i=0; i<noofedges; i++) {
|
||||||
edge = new MAT_Edge();
|
edge = new MAT_Edge();
|
||||||
@ -1103,6 +1107,7 @@ void MAT2d_Mat2d::CreateMat(MAT2d_Tool2d& atool)
|
|||||||
currentbisectorlist->Next();
|
currentbisectorlist->Next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RemovedEdgesList->BackAdd(theedgelist->Current());
|
||||||
theedgelist->Unlink();
|
theedgelist->Unlink();
|
||||||
|
|
||||||
//-----------------------------------------------------------
|
//-----------------------------------------------------------
|
||||||
@ -1329,6 +1334,7 @@ void MAT2d_Mat2d::CreateMat(MAT2d_Tool2d& atool)
|
|||||||
->FirstBisector());
|
->FirstBisector());
|
||||||
|
|
||||||
for(j=0; j<noofarea(i); j++) {
|
for(j=0; j<noofarea(i); j++) {
|
||||||
|
RemovedEdgesList->BackAdd(theedgelist->Current());
|
||||||
theedgelist->Unlink();
|
theedgelist->Unlink();
|
||||||
theedgelist->Next();
|
theedgelist->Next();
|
||||||
shift++;
|
shift++;
|
||||||
@ -1710,3 +1716,41 @@ Standard_Boolean MAT2d_Mat2d::IsDone() const
|
|||||||
return isDone;
|
return isDone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : ~MAT2d_Mat2d
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
MAT2d_Mat2d::~MAT2d_Mat2d()
|
||||||
|
{
|
||||||
|
MAT_DataMapIteratorOfDataMapOfIntegerBisector itmap(bisectormap);
|
||||||
|
for (; itmap.More(); itmap.Next())
|
||||||
|
{
|
||||||
|
Handle(MAT_Bisector) aBisector = itmap.Value();
|
||||||
|
aBisector->FirstEdge(NULL);
|
||||||
|
aBisector->SecondEdge(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!theedgelist.IsNull())
|
||||||
|
{
|
||||||
|
theedgelist->First();
|
||||||
|
for (Standard_Integer i = 1; i <= theedgelist->Number(); i++)
|
||||||
|
{
|
||||||
|
Handle(MAT_Edge) anEdge = theedgelist->Current();
|
||||||
|
anEdge->FirstBisector(NULL);
|
||||||
|
anEdge->SecondBisector(NULL);
|
||||||
|
theedgelist->Next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!RemovedEdgesList.IsNull())
|
||||||
|
{
|
||||||
|
RemovedEdgesList->First();
|
||||||
|
for (Standard_Integer i = 1; i <= RemovedEdgesList->Number(); i++)
|
||||||
|
{
|
||||||
|
Handle(MAT_Edge) anEdge = RemovedEdgesList->Current();
|
||||||
|
anEdge->FirstBisector(NULL);
|
||||||
|
anEdge->SecondBisector(NULL);
|
||||||
|
RemovedEdgesList->Next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -44,6 +44,8 @@ public:
|
|||||||
//! Empty construtor.
|
//! Empty construtor.
|
||||||
Standard_EXPORT MAT2d_Mat2d(const Standard_Boolean IsOpenResult = Standard_False);
|
Standard_EXPORT MAT2d_Mat2d(const Standard_Boolean IsOpenResult = Standard_False);
|
||||||
|
|
||||||
|
Standard_EXPORT ~MAT2d_Mat2d();
|
||||||
|
|
||||||
//! Algoritm of computation of the bisecting locus.
|
//! Algoritm of computation of the bisecting locus.
|
||||||
Standard_EXPORT void CreateMat (MAT2d_Tool2d& aTool);
|
Standard_EXPORT void CreateMat (MAT2d_Tool2d& aTool);
|
||||||
|
|
||||||
@ -96,6 +98,7 @@ private:
|
|||||||
Standard_Integer thenumberofedges;
|
Standard_Integer thenumberofedges;
|
||||||
Standard_Boolean semiInfinite;
|
Standard_Boolean semiInfinite;
|
||||||
Handle(MAT_ListOfEdge) theedgelist;
|
Handle(MAT_ListOfEdge) theedgelist;
|
||||||
|
Handle(MAT_ListOfEdge) RemovedEdgesList;
|
||||||
TColStd_DataMapOfIntegerInteger typeofbisectortoremove;
|
TColStd_DataMapOfIntegerInteger typeofbisectortoremove;
|
||||||
MAT_DataMapOfIntegerBisector bisectoronetoremove;
|
MAT_DataMapOfIntegerBisector bisectoronetoremove;
|
||||||
MAT_DataMapOfIntegerBisector bisectortwotoremove;
|
MAT_DataMapOfIntegerBisector bisectortwotoremove;
|
||||||
|
22
tests/bugs/modalg_7/bug31120
Normal file
22
tests/bugs/modalg_7/bug31120
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
puts "================================================="
|
||||||
|
puts "OCC31120: Memory leak in BRepOffsetAPI_MakeOffset"
|
||||||
|
puts "================================================="
|
||||||
|
puts ""
|
||||||
|
|
||||||
|
restore [locate_data_file bug31120_wire.brep] w
|
||||||
|
|
||||||
|
mkoffset r w 1 0.5
|
||||||
|
set log [meminfo h]
|
||||||
|
regexp {([0-9+-.eE]*)} $log full memval1
|
||||||
|
|
||||||
|
for {set i 0} {$i < 20} {incr i} {
|
||||||
|
mkoffset r w 1 0.5
|
||||||
|
set log [meminfo h]
|
||||||
|
regexp {([0-9+-.eE]*)} $log full memval
|
||||||
|
|
||||||
|
set ratio (${memval}-{$memval1})/${memval1}
|
||||||
|
|
||||||
|
if { ${ratio} > 0.05} {
|
||||||
|
puts "Error: memory leak"
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user