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.
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 :
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;
// 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
}
}
+//=======================================================================
+//function : Clear
+//purpose :
+//=======================================================================
+void BinLDrivers_DocumentRetrievalDriver::Clear()
+{
+ myPAtt.Destroy(); // free buffer
+ myRelocTable.Clear();
+ myMapUnsupported.Clear();
+}
+
//=======================================================================
//function : PropagateDocumentVersion
//purpose :
//! 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.
--- /dev/null
+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"
+}