mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-05 18:16:23 +03:00
0027604: Application Framework - memory is not released after closing XBF file
Virtual method *BinLDrivers_DocumentRetrievalDriver::Clear* now allows to Clear a cash data accumulated during a reading. So, in successor class BinDrivers_DocumentRetrievalDriver this allows clearing the BinMNaming_NamedShapeDriver set of stored shapes when it is not needed anymore.
This commit is contained in:
parent
c8c250a59d
commit
bf95447514
@ -90,6 +90,23 @@ void BinDrivers_DocumentRetrievalDriver::CheckShapeSection(
|
||||
Standard_IStream& /*IS*/)
|
||||
{}
|
||||
|
||||
//=======================================================================
|
||||
//function : Clear
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BinDrivers_DocumentRetrievalDriver::Clear()
|
||||
{
|
||||
// Clear NamedShape driver
|
||||
Handle(BinMDF_ADriver) aDriver;
|
||||
if (myDrivers->GetDriver(STANDARD_TYPE(TNaming_NamedShape), aDriver))
|
||||
{
|
||||
Handle(BinMNaming_NamedShapeDriver) aNamedShapeDriver =
|
||||
Handle(BinMNaming_NamedShapeDriver)::DownCast(aDriver);
|
||||
aNamedShapeDriver->Clear();
|
||||
}
|
||||
BinLDrivers_DocumentRetrievalDriver::Clear();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : PropagateDocumentVersion
|
||||
//purpose :
|
||||
|
@ -47,6 +47,9 @@ public:
|
||||
Standard_EXPORT virtual void ReadShapeSection (BinLDrivers_DocumentSection& theSection, Standard_IStream& theIS, const Standard_Boolean isMess = Standard_False) Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT virtual void CheckShapeSection (const Storage_Position& thePos, Standard_IStream& theIS) Standard_OVERRIDE;
|
||||
|
||||
//! Clears the NamedShape driver
|
||||
Standard_EXPORT virtual void Clear() Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT virtual void PropagateDocumentVersion (const Standard_Integer theVersion) Standard_OVERRIDE;
|
||||
|
||||
|
@ -297,9 +297,7 @@ void BinLDrivers_DocumentRetrievalDriver::Read (Standard_IStream&
|
||||
|
||||
// read sub-tree of the root label
|
||||
Standard_Integer nbRead = ReadSubTree (theIStream, aData->Root());
|
||||
myPAtt.Destroy(); // free buffer
|
||||
myRelocTable.Clear();
|
||||
myMapUnsupported.Clear();
|
||||
Clear();
|
||||
|
||||
if (nbRead > 0) {
|
||||
// attach data to the document
|
||||
@ -491,6 +489,17 @@ void BinLDrivers_DocumentRetrievalDriver::CheckShapeSection(
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Clear
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BinLDrivers_DocumentRetrievalDriver::Clear()
|
||||
{
|
||||
myPAtt.Destroy(); // free buffer
|
||||
myRelocTable.Clear();
|
||||
myMapUnsupported.Clear();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : PropagateDocumentVersion
|
||||
//purpose :
|
||||
|
@ -83,10 +83,16 @@ protected:
|
||||
//! define the procedure of reading a section to file.
|
||||
Standard_EXPORT virtual void ReadSection (BinLDrivers_DocumentSection& theSection, const Handle(CDM_Document)& theDoc, Standard_IStream& theIS);
|
||||
|
||||
//! define the procedure of reading a shapes section to file.
|
||||
Standard_EXPORT virtual void ReadShapeSection (BinLDrivers_DocumentSection& theSection, Standard_IStream& theIS, const Standard_Boolean isMess = Standard_False);
|
||||
|
||||
//! checks the shapes section can be correctly retreived.
|
||||
Standard_EXPORT virtual void CheckShapeSection (const Storage_Position& thePos, Standard_IStream& theIS);
|
||||
|
||||
|
||||
//! clears the reading-cash data in drivers if any.
|
||||
Standard_EXPORT virtual void Clear();
|
||||
|
||||
//! provides the version of document to all drivers
|
||||
Standard_EXPORT virtual void PropagateDocumentVersion (const Standard_Integer theVersion);
|
||||
|
||||
//! Check a file version(in which file was written) with a current version.
|
||||
|
39
tests/bugs/caf/bug27604
Normal file
39
tests/bugs/caf/bug27604
Normal file
@ -0,0 +1,39 @@
|
||||
puts "========"
|
||||
puts "OCC27604"
|
||||
puts "Application Framework - memory is not released after closing XBF file"
|
||||
puts "========"
|
||||
puts ""
|
||||
|
||||
set aBigShape Bottom.brep
|
||||
|
||||
pload OCAF MODELING
|
||||
|
||||
# just a big shape to fit in memory
|
||||
restore [locate_data_file $aBigShape] s
|
||||
|
||||
# store it in the document
|
||||
NewDocument D BinOcaf
|
||||
SetShape D "0:2" s
|
||||
SaveAs D test.cbf
|
||||
Close D
|
||||
|
||||
# store the memory used before opening a document
|
||||
set aBefore [meminfo h]
|
||||
|
||||
Open test.cbf DD
|
||||
set aDocLoaded [meminfo h]
|
||||
set aBigDelta [expr $aDocLoaded - $aBefore]
|
||||
Close DD
|
||||
|
||||
set anAfter [meminfo h]
|
||||
set aDelta [expr $anAfter - $aBefore]
|
||||
|
||||
puts "Memory used before: $aBefore"
|
||||
puts "After open: $aDocLoaded"
|
||||
puts "After close: $anAfter"
|
||||
|
||||
# if after the close the memory used left 5% more than before closed, this is an issue
|
||||
# (less 5% is the measurement tolerance)
|
||||
if {[expr $aBigDelta / 20. - $aDelta] < 0} {
|
||||
puts "Error: the memory is not freed after Open/Close"
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user