MantisBT - Open CASCADE
View Issue Details
0027604Open CASCADE[OCCT] OCCT:Application Frameworkpublic2016-06-14 18:282016-12-09 16:38
kgv 
apn 
normalminor 
closedfixed 
[OCCT] 7.0.0 
[OCCT] 7.1.0[OCCT] 7.1.0 
bugs caf bug27604
0027604: Application Framework - memory is not released after closing XBF file
BinLDrivers_DocumentRetrievalDriver uses BinMNaming_NamedShapeDriver, which creates map of shapes. While reading XBF file this map is filled up, however after reading is done the map is still there and even closing the document does not release the memory.

The following code can be found in some applications as a workaround, but it can not be justified:
class CustomDriver : public BinXCAFDrivers_DocumentRetrievalDriver
{
public:
  virtual void Read (Standard_IStream&               theIStream,
                     const Handle(Storage_Data)&     theStorageData,
                     const Handle(CDM_Document)&     theDoc,
                     const Handle(CDM_Application)&  theApplication)
  {
    BinLDrivers_DocumentRetrievalDriver::Read (theIStream, theStorageData, theDoc, theApplication);
    
if (!myDrivers.IsNull())
    {
      Handle(BinMDF_ADriver) aDriver;
      myDrivers->GetDriver (STANDARD_TYPE(TNaming_NamedShape), aDriver);
      Handle(BinMNaming_NamedShapeDriver) aShapesDriver = Handle(BinMNaming_NamedShapeDriver)::DownCast 
(aDriver);
      if (!aShapesDriver.IsNull())
      {
        aShapesDriver->Clear();
      }
    }
bugs caf bug27604
No tags attached.
Issue History
2016-06-14 18:28kgvNew Issue
2016-06-14 18:28kgvAssigned To => mpv
2016-10-12 11:02gitNote Added: 0058602
2016-10-12 11:11mpvSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=14933#r14933
2016-10-12 11:12mpvNote Added: 0058604
2016-10-12 11:12mpvAssigned Tompv => szy
2016-10-12 11:12mpvStatusnew => resolved
2016-10-12 14:18kgvNote Added: 0058615
2016-10-12 14:55gitNote Added: 0058616
2016-10-13 18:17szyNote Added: 0058686
2016-10-13 18:17szyAssigned Toszy => bugmaster
2016-10-13 18:17szyStatusresolved => reviewed
2016-10-13 18:41mkvAssigned Tobugmaster => mkv
2016-10-14 15:01mkvNote Added: 0058730
2016-10-14 15:01mkvAssigned Tomkv => mpv
2016-10-14 15:01mkvStatusreviewed => feedback
2016-10-14 15:51gitNote Added: 0058740
2016-10-14 15:57mpvNote Added: 0058741
2016-10-14 15:57mpvAssigned Tompv => mkv
2016-10-14 15:57mpvStatusfeedback => reviewed
2016-10-17 13:02mkvNote Added: 0058782
2016-10-17 13:03mkvNote Added: 0058783
2016-10-17 13:03mkvAssigned Tomkv => bugmaster
2016-10-17 13:03mkvStatusreviewed => tested
2016-10-17 13:03mkvTest case number => bugs caf bug27604
2016-10-21 11:25apnChangeset attached => occt master bf954475
2016-10-21 11:25apnAssigned Tobugmaster => apn
2016-10-21 11:25apnStatustested => verified
2016-10-21 11:25apnResolutionopen => fixed
2016-10-28 21:41gitNote Added: 0059438
2016-10-28 21:41gitNote Added: 0059439
2016-12-09 16:30aivStatusverified => closed
2016-12-09 16:38aivFixed in Version => 7.1.0

Notes
(0058602)
git   
2016-10-12 11:02   
Branch CR27604 has been created by mpv.

SHA-1: 555868e314dc991061fbfedafb48e94b4ad7ee24


Detailed log of new commits:

Author: mpv
Date: Wed Oct 12 11:02:02 2016 +0300

     Application Framework - memory is not released after closing XBF file
(0058604)
mpv   
2016-10-12 11:12   
Patch is ready for review. Branch CR27604.
(0058615)
kgv   
2016-10-12 14:18   
-  Standard_EXPORT virtual Handle(BinMDF_ADriverTable) AttributeDrivers (const Handle(CDM_MessageDriver)& 
theMsgDriver) Standard_OVERRIDE;
+  Standard_EXPORT virtual Handle(BinMDF_ADriverTable) AttributeDrivers(const Handle(CDM_MessageDriver)& 
theMsgDriver) Standard_OVERRIDE;
   
-  Standard_EXPORT virtual void ReadShapeSection (BinLDrivers_DocumentSection& theSection, Standard_IStream& 
theIS, const Standard_Boolean isMess = Standard_False) Standard_OVERRIDE;
+  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;
+  Standard_EXPORT virtual void CheckShapeSection(const Storage_Position& thePos, Standard_IStream& 
theIS) Standard_OVERRIDE;

Please avoid mixing cosmetic and functional changes within the same patch.
Note that this bracket spacing change contradicts to recommended coding style - see chapter "Separating spaces" and related code samples:
https://dev.opencascade.org/doc/overview/html/occt_dev_guides__coding_rules.html#occt_coding_rules_3 [^]
(0058616)
git   
2016-10-12 14:55   
Branch CR27604 has been updated by mpv.

SHA-1: d9ab5b14589f85c0af6f0c9522cb40d599f7c787


Detailed log of new commits:

Author: mpv
Date: Wed Oct 12 14:48:50 2016 +0300

    Roll back of cosmetic changes

(0058686)
szy   
2016-10-13 18:17   
Reviewed.
(0058730)
mkv   
2016-10-14 15:01   
Dear mpv,
could you please rebase branch CR27604 on current master, there are conflict files.
SHA-1: d9ab5b14589f85c0af6f0c9522cb40d599f7c787
(0058740)
git   
2016-10-14 15:51   
Branch CR27604_1 has been created by mpv.

SHA-1: 4ac5e2b9ce5a90539961d4e07cd5ab431051edbd


Detailed log of new commits:

Author: mpv
Date: Wed Oct 12 11:02:02 2016 +0300

     Application Framework - memory is not released after closing XBF file

Author: mpv
Date: Wed Oct 12 14:48:50 2016 +0300

    Roll back of cosmetic changes
(0058741)
mpv   
2016-10-14 15:57   
The rebased branch CR27604_1 is created.
(0058782)
mkv   
2016-10-17 13:02   
Dear BugMaster,
Branch CR27604_1 from occt git-repository (and master from products git-repository) was compiled on Linux, MacOS and Windows platforms and tested on Release mode.
SHA-1: 4ac5e2b9ce5a90539961d4e07cd5ab431051edbd

Number of compiler warnings:

occt component :
Linux: 0 (0 on master)
Windows: 0 (0 on master)
MacOS : 0 (0 on master)

products component :
Linux: 64 (64 on master)
Windows: 0 (0 on master)
MacOS : 1136

Regressions/Differences/Improvements:
No regressions/differences

Testing cases:
http://occt-tests/CR27604_1-master-OCCT/Debian70-64/bugs/caf/bug27604.html [^]

http://occt-tests/CR27604_1-master-OCCT/Windows-64-VC10/bugs/caf/bug27604.html [^]

bugs caf bug27604: OK

Testing on Linux:
occt component :
Total MEMORY difference: 90594299 / 90590165 [+0.00%]
Total CPU difference: 19445.61999999991 / 19464.819999999938 [-0.10%]
products component :
Total MEMORY difference: 30069952 / 30069397 [+0.00%]
Total CPU difference: 5301.37999999998 / 5271.849999999968 [+0.56%]

Testing on Windows:
occt component :
Total MEMORY difference: 57228459 / 57250244 [-0.04%]
Total CPU difference: 18863.204117198624 / 18101.186032498666 [+4.21%]
products component :
Total MEMORY difference: 21302935 / 21265221 [+0.18%]
Total CPU difference: 5502.560872599972 / 5148.189000999964 [+6.88%]

There are no differences in images found by testdiff.
(0058783)
mkv   
2016-10-17 13:03   
Dear BugMaster,
Branch CR27604_1 is TESTED.
(0059438)
git   
2016-10-28 21:41   
Branch CR27604 has been deleted by kgv.

SHA-1: d9ab5b14589f85c0af6f0c9522cb40d599f7c787
(0059439)
git   
2016-10-28 21:41   
Branch CR27604_1 has been deleted by kgv.

SHA-1: 4ac5e2b9ce5a90539961d4e07cd5ab431051edbd