Salome HOME
Modification of the getHeapMemorySize computation.
authorageay <ageay>
Wed, 21 Aug 2013 11:06:27 +0000 (11:06 +0000)
committerageay <ageay>
Wed, 21 Aug 2013 11:06:27 +0000 (11:06 +0000)
56 files changed:
src/MEDCalculator/MEDCalculatorDBField.cxx
src/MEDCalculator/MEDCalculatorDBField.hxx
src/MEDCalculator/MEDCalculatorDBSliceField.cxx
src/MEDCalculator/MEDCalculatorDBSliceField.hxx
src/MEDCoupling/MEDCoupling1GTUMesh.cxx
src/MEDCoupling/MEDCoupling1GTUMesh.hxx
src/MEDCoupling/MEDCouplingCMesh.cxx
src/MEDCoupling/MEDCouplingCMesh.hxx
src/MEDCoupling/MEDCouplingCurveLinearMesh.cxx
src/MEDCoupling/MEDCouplingCurveLinearMesh.hxx
src/MEDCoupling/MEDCouplingDefinitionTime.cxx
src/MEDCoupling/MEDCouplingDefinitionTime.hxx
src/MEDCoupling/MEDCouplingExtrudedMesh.cxx
src/MEDCoupling/MEDCouplingExtrudedMesh.hxx
src/MEDCoupling/MEDCouplingField.cxx
src/MEDCoupling/MEDCouplingField.hxx
src/MEDCoupling/MEDCouplingFieldDiscretization.cxx
src/MEDCoupling/MEDCouplingFieldDiscretization.hxx
src/MEDCoupling/MEDCouplingFieldDouble.cxx
src/MEDCoupling/MEDCouplingFieldDouble.hxx
src/MEDCoupling/MEDCouplingMemArray.cxx
src/MEDCoupling/MEDCouplingMemArray.hxx
src/MEDCoupling/MEDCouplingMemArrayChar.cxx
src/MEDCoupling/MEDCouplingMesh.cxx
src/MEDCoupling/MEDCouplingMesh.hxx
src/MEDCoupling/MEDCouplingMultiFields.cxx
src/MEDCoupling/MEDCouplingMultiFields.hxx
src/MEDCoupling/MEDCouplingPointSet.cxx
src/MEDCoupling/MEDCouplingPointSet.hxx
src/MEDCoupling/MEDCouplingRefCountObject.cxx
src/MEDCoupling/MEDCouplingRefCountObject.hxx
src/MEDCoupling/MEDCouplingStructuredMesh.cxx
src/MEDCoupling/MEDCouplingStructuredMesh.hxx
src/MEDCoupling/MEDCouplingTimeDiscretization.cxx
src/MEDCoupling/MEDCouplingTimeDiscretization.hxx
src/MEDCoupling/MEDCouplingUMesh.cxx
src/MEDCoupling/MEDCouplingUMesh.hxx
src/MEDLoader/MEDFileData.cxx
src/MEDLoader/MEDFileData.hxx
src/MEDLoader/MEDFileField.cxx
src/MEDLoader/MEDFileField.hxx
src/MEDLoader/MEDFileFieldOverView.cxx
src/MEDLoader/MEDFileFieldOverView.hxx
src/MEDLoader/MEDFileMesh.cxx
src/MEDLoader/MEDFileMesh.hxx
src/MEDLoader/MEDFileMeshElt.cxx
src/MEDLoader/MEDFileMeshElt.hxx
src/MEDLoader/MEDFileMeshLL.cxx
src/MEDLoader/MEDFileMeshLL.hxx
src/MEDLoader/MEDFileParameter.cxx
src/MEDLoader/MEDFileParameter.hxx
src/MEDLoader/SauvReader.cxx
src/MEDLoader/SauvReader.hxx
src/MEDLoader/SauvUtilities.hxx
src/MEDLoader/SauvWriter.cxx
src/MEDLoader/SauvWriter.hxx

index c04c68aaff1b889eb752a18ced3663ae4b148fe6..78110d2cc6ae4b9625a0c40a11df47a92637f54f 100644 (file)
@@ -46,6 +46,16 @@ MEDCalculatorDBFieldCst *MEDCalculatorDBField::New(double val)
   return new MEDCalculatorDBFieldCst(val);
 }
 
+std::size_t MEDCalculatorDBField::getHeapMemorySizeWithoutChildren() const
+{
+  return 0;
+}
+
+std::vector<RefCountObject *> MEDCalculatorDBField::getDirectChildren() const
+{
+  return std::vector<RefCountObject *>();
+}
+
 MEDCalculatorDBField *MEDCalculatorDBField::operator+(double val) const throw(INTERP_KERNEL::Exception)
 {
   MEDCouplingAutoRefCountObjectPtr<MEDCalculatorDBFieldCst> par2=new MEDCalculatorDBFieldCst(val);
index 16b85d2c2b18ec02d0b591cf73668910e1b174f3..6809b9659491682cb7dbecd133499f958f2d265a 100644 (file)
@@ -45,7 +45,8 @@ namespace ParaMEDMEM
   public:
     static MEDCalculatorDBFieldReal *New(const MEDCalculatorBrowserField& ls);
     static MEDCalculatorDBFieldCst *New(double val);
-    std::size_t getHeapMemorySize() const { return 0; }
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<RefCountObject *> getDirectChildren() const;
     virtual MEDCalculatorDBField *operator+(const MEDCalculatorDBField& other) const throw(INTERP_KERNEL::Exception) = 0;
     MEDCalculatorDBField *operator+(double val) const throw(INTERP_KERNEL::Exception);
     virtual MEDCalculatorDBField *operator-(const MEDCalculatorDBField& other) const throw(INTERP_KERNEL::Exception) = 0;
index 450dc68eff2851daad7d2fc1d091c7c0cf5414fa..b559c079b23fcad132a12914b56c57679ed53cce 100644 (file)
@@ -36,6 +36,16 @@ MEDCalculatorDBSliceField::MEDCalculatorDBSliceField(MEDCouplingFieldDouble *f):
 {
 }
 
+std::size_t MEDCalculatorDBSliceField::getHeapMemorySizeWithoutChildren() const
+{
+  return 0;
+}
+
+std::vector<RefCountObject *> MEDCalculatorDBSliceField::getDirectChildren() const
+{
+  return std::vector<RefCountObject *>();
+}
+
 void MEDCalculatorDBSliceField::setField(MEDCouplingFieldDouble *f) const
 {
   if(_field!=f)
index f13f5e9d96b186d023a7720996cbce52abea7b57..35de50da9eb668ea01f7ea9a2873bbf8efea3c8f 100644 (file)
@@ -40,7 +40,8 @@ namespace ParaMEDMEM
   public:
     MEDCalculatorDBSliceField(int iter, int order);
     MEDCalculatorDBSliceField(MEDCouplingFieldDouble *f);
-    std::size_t getHeapMemorySize() const { return 0; }
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<RefCountObject *> getDirectChildren() const;
     bool isFetched() const { return _field!=0; }
     void getDtIt(int& it, int& order) const { it=_iteration;  order=_order; }
     void setField(MEDCouplingFieldDouble *f) const;
index 7bb67e8f9a00454fb4e447237e8de38330d8cb43..8805521823a1ef1403b40e8bfe270de4c23fa071 100644 (file)
@@ -248,9 +248,9 @@ std::string MEDCoupling1GTUMesh::getVTKDataSetType() const throw(INTERP_KERNEL::
   return std::string("UnstructuredGrid");
 }
 
-std::size_t MEDCoupling1GTUMesh::getHeapMemorySize() const
+std::size_t MEDCoupling1GTUMesh::getHeapMemorySizeWithoutChildren() const
 {
-  return MEDCouplingPointSet::getHeapMemorySize();
+  return MEDCouplingPointSet::getHeapMemorySizeWithoutChildren();
 }
 
 bool MEDCoupling1GTUMesh::isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const throw(INTERP_KERNEL::Exception)
@@ -567,13 +567,18 @@ void MEDCoupling1SGTUMesh::updateTime() const
     updateTimeWith(*c);
 }
 
-std::size_t MEDCoupling1SGTUMesh::getHeapMemorySize() const
+std::size_t MEDCoupling1SGTUMesh::getHeapMemorySizeWithoutChildren() const
 {
-  std::size_t ret=0;
+  return MEDCoupling1GTUMesh::getHeapMemorySizeWithoutChildren();
+}
+
+std::vector<RefCountObject *> MEDCoupling1SGTUMesh::getDirectChildren() const
+{
+  std::vector<RefCountObject *> ret(MEDCoupling1GTUMesh::getDirectChildren());
   const DataArrayInt *c(_conn);
   if(c)
-    ret+=c->getHeapMemorySize();
-  return MEDCoupling1GTUMesh::getHeapMemorySize()+ret;
+    ret.push_back(const_cast<DataArrayInt *>(c));
+  return ret;
 }
 
 MEDCouplingMesh *MEDCoupling1SGTUMesh::deepCpy() const
@@ -1899,16 +1904,21 @@ void MEDCoupling1DGTUMesh::updateTime() const
     updateTimeWith(*c);
 }
 
-std::size_t MEDCoupling1DGTUMesh::getHeapMemorySize() const
+std::size_t MEDCoupling1DGTUMesh::getHeapMemorySizeWithoutChildren() const
 {
-  std::size_t ret=0;
+  return MEDCoupling1GTUMesh::getHeapMemorySizeWithoutChildren();
+}
+
+std::vector<RefCountObject *> MEDCoupling1DGTUMesh::getDirectChildren() const
+{
+  std::vector<RefCountObject *> ret(MEDCoupling1GTUMesh::getDirectChildren());
   const DataArrayInt *c(_conn);
   if(c)
-    ret+=c->getHeapMemorySize();
+    ret.push_back(const_cast<DataArrayInt *>(c));
   c=_conn_indx;
   if(c)
-    ret+=c->getHeapMemorySize();
-  return MEDCoupling1GTUMesh::getHeapMemorySize()+ret;
+    ret.push_back(const_cast<DataArrayInt *>(c));
+  return ret;
 }
 
 MEDCouplingMesh *MEDCoupling1DGTUMesh::deepCpy() const
index 8b0cd87525efb15f15364aaaef831501adc0b2c1..bb51d043e8271ff6006626967c3fc998e472d6c7 100644 (file)
@@ -50,7 +50,7 @@ namespace ParaMEDMEM
     MEDCOUPLING_EXPORT void writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData, DataArrayByte *byteData) const throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT std::string getVTKDataSetType() const throw(INTERP_KERNEL::Exception);
     //
-    MEDCOUPLING_EXPORT std::size_t getHeapMemorySize() const;
+    MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
     MEDCOUPLING_EXPORT int getNodalConnectivityLength() const throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const;
@@ -93,7 +93,8 @@ namespace ParaMEDMEM
     MEDCOUPLING_EXPORT MEDCouplingPointSet *deepCpyConnectivityOnly() const throw(INTERP_KERNEL::Exception);
     // overload of TimeLabel and RefCountObject
     MEDCOUPLING_EXPORT void updateTime() const;
-    MEDCOUPLING_EXPORT std::size_t getHeapMemorySize() const;
+    MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
+    MEDCOUPLING_EXPORT std::vector<RefCountObject *> getDirectChildren() const;
     // overload of MEDCouplingMesh
     MEDCOUPLING_EXPORT MEDCouplingMeshType getType() const { return SINGLE_STATIC_GEO_TYPE_UNSTRUCTURED; }
     MEDCOUPLING_EXPORT MEDCouplingMesh *deepCpy() const;
@@ -177,7 +178,8 @@ namespace ParaMEDMEM
     MEDCOUPLING_EXPORT MEDCouplingPointSet *deepCpyConnectivityOnly() const throw(INTERP_KERNEL::Exception);
     // overload of TimeLabel and RefCountObject
     MEDCOUPLING_EXPORT void updateTime() const;
-    MEDCOUPLING_EXPORT std::size_t getHeapMemorySize() const;
+    MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
+    MEDCOUPLING_EXPORT std::vector<RefCountObject *> getDirectChildren() const;
     // overload of MEDCouplingMesh
     MEDCOUPLING_EXPORT MEDCouplingMeshType getType() const { return SINGLE_DYNAMIC_GEO_TYPE_UNSTRUCTURED; }
     MEDCOUPLING_EXPORT MEDCouplingMesh *deepCpy() const;
index d6b5e13b7f2d6732b04e38c0547fe102c28172b7..70d3c7a6a6f35c01316a26a57f64637547ad8e51 100644 (file)
@@ -106,16 +106,21 @@ void MEDCouplingCMesh::updateTime() const
     updateTimeWith(*_z_array);
 }
 
-std::size_t MEDCouplingCMesh::getHeapMemorySize() const
-{
-  std::size_t ret=0;
-  std::set<DataArrayDouble *> s;
-  s.insert(_x_array); s.insert(_y_array); s.insert(_z_array);
-  s.erase(NULL);
-  for(std::set<DataArrayDouble *>::const_iterator it=s.begin();it!=s.end();it++)
-    if(*it)
-      ret+=(*it)->getHeapMemorySize();
-  return MEDCouplingStructuredMesh::getHeapMemorySize()+ret;
+std::size_t MEDCouplingCMesh::getHeapMemorySizeWithoutChildren() const
+{
+  return MEDCouplingStructuredMesh::getHeapMemorySizeWithoutChildren();
+}
+
+std::vector<RefCountObject *> MEDCouplingCMesh::getDirectChildren() const
+{
+  std::vector<RefCountObject *> ret;
+  if(_x_array)
+    ret.push_back(const_cast<DataArrayDouble *>(_x_array));
+  if(_y_array)
+    ret.push_back(const_cast<DataArrayDouble *>(_y_array));
+  if(_z_array)
+    ret.push_back(const_cast<DataArrayDouble *>(_z_array));
+  return ret;
 }
 
 /*!
index f3e02ee4b0c5a45074ccfe1007f8085515ca9adc..6d1cba871785f8c9ad10cda07a426e7fceaf9a6d 100644 (file)
@@ -37,7 +37,8 @@ namespace ParaMEDMEM
     MEDCouplingMesh *deepCpy() const;
     MEDCouplingCMesh *clone(bool recDeepCpy) const;
     void updateTime() const;
-    std::size_t getHeapMemorySize() const;
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<RefCountObject *> getDirectChildren() const;
     MEDCouplingMeshType getType() const { return CARTESIAN; }
     void copyTinyStringsFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception);
     bool isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const throw(INTERP_KERNEL::Exception);
index 7bfadc53f4579998b3a49901bba0182f46d8a7db..31ecee0948ec9ede082608a933374ada4bae4a68 100644 (file)
@@ -80,13 +80,19 @@ void MEDCouplingCurveLinearMesh::updateTime() const
     updateTimeWith(*_coords);
 }
 
-std::size_t MEDCouplingCurveLinearMesh::getHeapMemorySize() const
+std::size_t MEDCouplingCurveLinearMesh::getHeapMemorySizeWithoutChildren() const
 {
-  std::size_t ret=0;
+  std::size_t ret(MEDCouplingStructuredMesh::getHeapMemorySizeWithoutChildren());
   ret+=_structure.capacity()*sizeof(int);
+  return ret;
+}
+
+std::vector<RefCountObject *> MEDCouplingCurveLinearMesh::getDirectChildren() const
+{
+  std::vector<RefCountObject *> ret;
   if((const DataArrayDouble *)_coords)
-    ret+=_coords->getHeapMemorySize();
-  return MEDCouplingStructuredMesh::getHeapMemorySize()+ret;
+    ret.push_back(const_cast<DataArrayDouble *>((const DataArrayDouble *)_coords));
+  return ret;
 }
 
 /*!
index 66b2743445ebb1219838b060e5d2e1483c828625..13df6d043e7a4021f9756f2890f776ca9aaa224a 100644 (file)
@@ -38,7 +38,8 @@ namespace ParaMEDMEM
     MEDCouplingMesh *deepCpy() const;
     MEDCouplingCurveLinearMesh *clone(bool recDeepCpy) const;
     void updateTime() const;
-    std::size_t getHeapMemorySize() const;
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<RefCountObject *> getDirectChildren() const;
     MEDCouplingMeshType getType() const { return CURVE_LINEAR; }
     void copyTinyStringsFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception);
     bool isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const throw(INTERP_KERNEL::Exception);
index 45aa50c7af222d18b1f804432a5f24dace06c48a..19e4524618054afba1b36612b63f9a99719e0f25 100644 (file)
@@ -109,11 +109,16 @@ MEDCouplingDefinitionTimeSlice::MEDCouplingDefinitionTimeSlice(const MEDCoupling
     throw INTERP_KERNEL::Exception("MEDCouplingDefinitionTimeSlice : End time strictly before Start time ...");
 }
 
-std::size_t MEDCouplingDefinitionTimeSlice::getHeapMemorySize() const
+std::size_t MEDCouplingDefinitionTimeSlice::getHeapMemorySizeWithoutChildren() const
 {
   return 0;
 }
 
+std::vector<RefCountObject *> MEDCouplingDefinitionTimeSlice::getDirectChildren() const
+{
+  return std::vector<RefCountObject *>();
+}
+
 bool MEDCouplingDefinitionTimeSlice::isFullyIncludedInMe(const MEDCouplingDefinitionTimeSlice *other, double eps) const
 {
   double t1=getStartTime();
@@ -464,11 +469,16 @@ MEDCouplingDefinitionTime::MEDCouplingDefinitionTime(const std::vector<const MED
     }
 }
 
-std::size_t MEDCouplingDefinitionTime::getHeapMemorySize() const
+std::size_t MEDCouplingDefinitionTime::getHeapMemorySizeWithoutChildren() const
 {
   return _slices.capacity()*(sizeof(MEDCouplingDefinitionTimeSlice)+sizeof(int));
 }
 
+std::vector<RefCountObject *> MEDCouplingDefinitionTime::getDirectChildren() const
+{
+  return std::vector<RefCountObject *>();
+}
+
 void MEDCouplingDefinitionTime::assign(const MEDCouplingDefinitionTime& other)
 {
   std::size_t sz=other._slices.size();
index f6380d0e6ef027f2ec78a4ccaf82e308eaa7325f..deb519243fdf864716d1ba553dd48b6dedb3ee5e 100644 (file)
@@ -51,7 +51,8 @@ namespace ParaMEDMEM
     virtual double getEndTime() const = 0;
     virtual void getTinySerializationInformation(std::vector<int>& tiI, std::vector<double>& tiD) const = 0;
     virtual TypeOfTimeDiscretization getTimeType() const = 0;
-    std::size_t getHeapMemorySize() const;
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<RefCountObject *> getDirectChildren() const;
     bool isFullyIncludedInMe(const MEDCouplingDefinitionTimeSlice *other, double eps) const;
     bool isOverllapingWithMe(const MEDCouplingDefinitionTimeSlice *other, double eps) const;
     bool isAfterMe(const MEDCouplingDefinitionTimeSlice *other, double eps) const;
@@ -143,7 +144,8 @@ namespace ParaMEDMEM
   public:
     MEDCouplingDefinitionTime();
     MEDCouplingDefinitionTime(const std::vector<const MEDCouplingFieldDouble *>& fs, const std::vector<int>& meshRefs, const std::vector<std::vector<int> >& arrRefs) throw(INTERP_KERNEL::Exception);
-    std::size_t getHeapMemorySize() const;
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<RefCountObject *> getDirectChildren() const;
     void assign(const MEDCouplingDefinitionTime& other);
     bool isEqual(const MEDCouplingDefinitionTime& other) const;
     double getTimeResolution() const { return _eps; }
index fd36040373e98a3f81700fbc3bbd99eecc09daee..14a29179d878a0f516275f8a8ced18a4af573f79 100644 (file)
@@ -64,16 +64,21 @@ MEDCouplingMeshType MEDCouplingExtrudedMesh::getType() const
   return EXTRUDED;
 }
 
-std::size_t MEDCouplingExtrudedMesh::getHeapMemorySize() const
+std::size_t MEDCouplingExtrudedMesh::getHeapMemorySizeWithoutChildren() const
 {
-  std::size_t ret=0;
+  return MEDCouplingMesh::getHeapMemorySizeWithoutChildren();
+}
+
+std::vector<RefCountObject *> MEDCouplingExtrudedMesh::getDirectChildren() const
+{
+  std::vector<RefCountObject *> ret;
   if(_mesh2D)
-    ret+=_mesh2D->getHeapMemorySize();
+    ret.push_back(const_cast<MEDCouplingUMesh *>(_mesh2D));
   if(_mesh1D)
-    ret+=_mesh1D->getHeapMemorySize();
+    ret.push_back(const_cast<MEDCouplingUMesh *>(_mesh1D));
   if(_mesh3D_ids)
-    ret+=_mesh3D_ids->getHeapMemorySize();
-  return MEDCouplingMesh::getHeapMemorySize()+ret;
+    ret.push_back(const_cast<DataArrayInt *>(_mesh3D_ids));
+  return ret;
 }
 
 /*!
index 1c97019ad3dc86546350a3219c002a053671c8af..8aa72199df8cd87e5e25debc215a2a036e8e34e6 100644 (file)
@@ -39,7 +39,8 @@ namespace ParaMEDMEM
     static MEDCouplingExtrudedMesh *New(const MEDCouplingUMesh *mesh3D, const MEDCouplingUMesh *mesh2D, int cell2DId) throw(INTERP_KERNEL::Exception);
     static MEDCouplingExtrudedMesh *New();
     MEDCouplingMeshType getType() const;
-    std::size_t getHeapMemorySize() const;
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<RefCountObject *> getDirectChildren() const;
     void copyTinyStringsFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception);
     int getNumberOfCells() const;
     int getNumberOfNodes() const;
index b00d779eeeca5a6dae9de9bb18c22e4ad310d03d..c7813180aa25a004229a67dbf6fd6149bf2f65ec 100644 (file)
@@ -153,15 +153,21 @@ void MEDCouplingField::updateTime() const
     updateTimeWith(*_type);
 }
 
-std::size_t MEDCouplingField::getHeapMemorySize() const
+std::size_t MEDCouplingField::getHeapMemorySizeWithoutChildren() const
 {
   std::size_t ret=0;
   ret+=_name.capacity();
   ret+=_desc.capacity();
+  return ret;
+}
+
+std::vector<RefCountObject *> MEDCouplingField::getDirectChildren() const
+{
+  std::vector<RefCountObject *> ret;
   if(_mesh)
-    ret+=_mesh->getHeapMemorySize();
+    ret.push_back(const_cast<MEDCouplingMesh *>(_mesh));
   if((const MEDCouplingFieldDiscretization *)_type)
-    ret+=_type->getHeapMemorySize();
+    ret.push_back(const_cast<MEDCouplingFieldDiscretization *>((const MEDCouplingFieldDiscretization *)_type));
   return ret;
 }
 
index 284d04799ffb7bdf72acacd7f4a2a54ff6ed8cbd..5cf5bbf080cfff1deb757e9c8eea147ade7370c4 100644 (file)
@@ -84,7 +84,8 @@ namespace ParaMEDMEM
     void getCellIdsHavingGaussLocalization(int locId, std::vector<int>& cellIds) const throw(INTERP_KERNEL::Exception);
     const MEDCouplingGaussLocalization& getGaussLocalization(int locId) const throw(INTERP_KERNEL::Exception);
     void updateTime() const;
-    std::size_t getHeapMemorySize() const;
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<RefCountObject *> getDirectChildren() const;
     // for MED file RW
     int getNumberOfTuplesExpectedRegardingCode(const std::vector<int>& code, const std::vector<const DataArrayInt *>& idsPerType) const throw(INTERP_KERNEL::Exception);
     virtual void reprQuickOverview(std::ostream& stream) const throw(INTERP_KERNEL::Exception) = 0;
index 4742a3ed08ce7f2d82f8bb8562d816bbdfd7a51b..04dc709084582968cdcdc0acc67a4d18e314a0c1 100644 (file)
@@ -179,11 +179,16 @@ void MEDCouplingFieldDiscretization::updateTime() const
 {
 }
 
-std::size_t MEDCouplingFieldDiscretization::getHeapMemorySize() const
+std::size_t MEDCouplingFieldDiscretization::getHeapMemorySizeWithoutChildren() const
 {
   return 0;
 }
 
+std::vector<RefCountObject *> MEDCouplingFieldDiscretization::getDirectChildren() const
+{
+  return std::vector<RefCountObject *>();
+}
+
 /*!
  * Computes normL1 of DataArrayDouble instance arr.
  * @param res output parameter expected to be of size arr->getNumberOfComponents();
@@ -1069,11 +1074,17 @@ void MEDCouplingFieldDiscretizationPerCell::updateTime() const
     updateTimeWith(*_discr_per_cell);
 }
 
-std::size_t MEDCouplingFieldDiscretizationPerCell::getHeapMemorySize() const
+std::size_t MEDCouplingFieldDiscretizationPerCell::getHeapMemorySizeWithoutChildren() const
+{
+  std::size_t ret(MEDCouplingFieldDiscretization::getHeapMemorySizeWithoutChildren());
+  return ret;
+}
+
+std::vector<RefCountObject *> MEDCouplingFieldDiscretizationPerCell::getDirectChildren() const
 {
-  std::size_t ret=0;
+  std::vector<RefCountObject *> ret(MEDCouplingFieldDiscretization::getDirectChildren());
   if(_discr_per_cell)
-    ret+=_discr_per_cell->getHeapMemorySize();
+    ret.push_back(const_cast<DataArrayInt *>(_discr_per_cell));
   return ret;
 }
 
@@ -1307,12 +1318,13 @@ std::string MEDCouplingFieldDiscretizationGauss::getStringRepr() const
   return oss.str();
 }
 
-std::size_t MEDCouplingFieldDiscretizationGauss::getHeapMemorySize() const
+std::size_t MEDCouplingFieldDiscretizationGauss::getHeapMemorySizeWithoutChildren() const
 {
-  std::size_t ret=_loc.capacity()*sizeof(MEDCouplingGaussLocalization);
+  std::size_t ret(MEDCouplingFieldDiscretizationPerCell::getHeapMemorySizeWithoutChildren());
+  ret+=_loc.capacity()*sizeof(MEDCouplingGaussLocalization);
   for(std::vector<MEDCouplingGaussLocalization>::const_iterator it=_loc.begin();it!=_loc.end();it++)
     ret+=(*it).getHeapMemorySize();
-  return MEDCouplingFieldDiscretizationPerCell::getHeapMemorySize()+ret;
+  return ret;
 }
 
 const char *MEDCouplingFieldDiscretizationGauss::getRepr() const
index 2cbd5511f7c4980d5d77646dd3b1d65cfb2864ee..a56d3b25cc4dba2386d2c57202565f41c0598902 100644 (file)
@@ -47,7 +47,8 @@ namespace ParaMEDMEM
     double getPrecision() const { return _precision; }
     void setPrecision(double val) { _precision=val; }
     void updateTime() const;
-    std::size_t getHeapMemorySize() const;
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<RefCountObject *> getDirectChildren() const;
     static TypeOfField GetTypeOfFieldFromStringRepr(const char *repr) throw(INTERP_KERNEL::Exception);
     virtual TypeOfField getEnum() const = 0;
     virtual bool isEqual(const MEDCouplingFieldDiscretization *other, double eps) const;
@@ -208,7 +209,8 @@ namespace ParaMEDMEM
     MEDCouplingFieldDiscretizationPerCell(const MEDCouplingFieldDiscretizationPerCell& other, int beginCellIds, int endCellIds, int stepCellIds);
     ~MEDCouplingFieldDiscretizationPerCell();
     void updateTime() const;
-    std::size_t getHeapMemorySize() const;
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<RefCountObject *> getDirectChildren() const;
     void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArray *da) const throw(INTERP_KERNEL::Exception);
     bool isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double eps, std::string& reason) const;
     bool isEqualWithoutConsideringStr(const MEDCouplingFieldDiscretization *other, double eps) const;
@@ -232,7 +234,7 @@ namespace ParaMEDMEM
     MEDCouplingFieldDiscretization *clonePartRange(int beginCellIds, int endCellIds, int stepCellIds) const;
     std::string getStringRepr() const;
     const char *getRepr() const;
-    std::size_t getHeapMemorySize() const;
+    std::size_t getHeapMemorySizeWithoutChildren() const;
     int getNumberOfTuplesExpectedRegardingCode(const MEDCouplingMesh *mesh, const std::vector<int>& code, const std::vector<const DataArrayInt *>& idsPerType) const throw(INTERP_KERNEL::Exception);
     int getNumberOfTuples(const MEDCouplingMesh *mesh) const throw(INTERP_KERNEL::Exception);
     int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const;
index b7b3711b501da4e4d001b280e1b4ceec6aa1f8df..954408c64c2fc164c57e6b73c1718e9032a35ee0 100644 (file)
@@ -1780,12 +1780,20 @@ void MEDCouplingFieldDouble::updateTime() const
   updateTimeWith(*_time_discr);
 }
 
-std::size_t MEDCouplingFieldDouble::getHeapMemorySize() const
+std::size_t MEDCouplingFieldDouble::getHeapMemorySizeWithoutChildren() const
 {
-  std::size_t ret=0;
+  return MEDCouplingField::getHeapMemorySizeWithoutChildren();
+}
+
+std::vector<RefCountObject *> MEDCouplingFieldDouble::getDirectChildren() const
+{
+  std::vector<RefCountObject *> ret(MEDCouplingField::getDirectChildren());
   if(_time_discr)
-    ret+=_time_discr->getHeapMemorySize();
-  return MEDCouplingField::getHeapMemorySize()+ret;
+    {
+      std::vector<RefCountObject *> ret2(_time_discr->getDirectChildren());
+      ret.insert(ret.end(),ret2.begin(),ret2.end());
+    }
+  return ret;
 }
 
 /*!
index 3a3533e8729515fdd7aa66c6bb1fe8ecf36b3386..a99041fede1f34a765a58f600d49f0ae4f73ed6e 100644 (file)
@@ -130,7 +130,8 @@ namespace ParaMEDMEM
     int getNumberOfTuples() const throw(INTERP_KERNEL::Exception);
     int getNumberOfValues() const throw(INTERP_KERNEL::Exception);
     void updateTime() const;
-    std::size_t getHeapMemorySize() const;
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<RefCountObject *> getDirectChildren() const;
     //
     void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
     void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
index 424a2098654b44c644a9cff89287ae819a56dd7c..3dc5f450decc7325bfac9422e264cd9f6596bda4 100644 (file)
@@ -110,7 +110,7 @@ void DataArrayDouble::FindClosestTupleIdAlg(const BBTreePts<SPACEDIM,int>& myTre
     }
 }
 
-std::size_t DataArray::getHeapMemorySize() const
+std::size_t DataArray::getHeapMemorySizeWithoutChildren() const
 {
   std::size_t sz1=_name.capacity();
   std::size_t sz2=_info_on_compo.capacity();
@@ -120,6 +120,11 @@ std::size_t DataArray::getHeapMemorySize() const
   return sz1+sz2+sz3;
 }
 
+std::vector<RefCountObject *> DataArray::getDirectChildren() const
+{
+  return std::vector<RefCountObject *>();
+}
+
 /*!
  * Sets the attribute \a _name of \a this array.
  * See \ref MEDCouplingArrayBasicsName "DataArrays infos" for more information.
@@ -748,11 +753,11 @@ void DataArrayDouble::desallocate() throw(INTERP_KERNEL::Exception)
   _mem.destroy();
 }
 
-std::size_t DataArrayDouble::getHeapMemorySize() const
+std::size_t DataArrayDouble::getHeapMemorySizeWithoutChildren() const
 {
-  std::size_t sz=_mem.getNbOfElemAllocated();
+  std::size_t sz(_mem.getNbOfElemAllocated());
   sz*=sizeof(double);
-  return DataArray::getHeapMemorySize()+sz;
+  return DataArray::getHeapMemorySizeWithoutChildren()+sz;
 }
 
 /*!
@@ -922,7 +927,7 @@ double DataArrayDouble::popBackSilent() throw(INTERP_KERNEL::Exception)
 /*!
  * This method \b do \b not modify content of \a this. It only modify its memory footprint if the allocated memory is to high regarding real data to store.
  *
- * \sa DataArrayDouble::getHeapMemorySize, DataArrayDouble::reserve
+ * \sa DataArrayDouble::getHeapMemorySizeWithoutChildren, DataArrayDouble::reserve
  */
 void DataArrayDouble::pack() const throw(INTERP_KERNEL::Exception)
 {
@@ -5614,11 +5619,11 @@ void DataArrayInt::desallocate() throw(INTERP_KERNEL::Exception)
   _mem.destroy();
 }
 
-std::size_t DataArrayInt::getHeapMemorySize() const
+std::size_t DataArrayInt::getHeapMemorySizeWithoutChildren() const
 {
-  std::size_t sz=_mem.getNbOfElemAllocated();
+  std::size_t sz(_mem.getNbOfElemAllocated());
   sz*=sizeof(int);
-  return DataArray::getHeapMemorySize()+sz;
+  return DataArray::getHeapMemorySizeWithoutChildren()+sz;
 }
 
 /*!
@@ -5808,7 +5813,7 @@ int DataArrayInt::popBackSilent() throw(INTERP_KERNEL::Exception)
 /*!
  * This method \b do \b not modify content of \a this. It only modify its memory footprint if the allocated memory is to high regarding real data to store.
  *
- * \sa DataArrayInt::getHeapMemorySize, DataArrayInt::reserve
+ * \sa DataArrayInt::getHeapMemorySizeWithoutChildren, DataArrayInt::reserve
  */
 void DataArrayInt::pack() const throw(INTERP_KERNEL::Exception)
 {
index 8d52c703326b11376c96a0016b5c1dea7eabf57b..6000da785e05b1cc94b9b0ff5c9377100ba7f389 100644 (file)
@@ -115,7 +115,8 @@ namespace ParaMEDMEM
   class DataArray : public RefCountObject, public TimeLabel
   {
   public:
-    MEDCOUPLING_EXPORT std::size_t getHeapMemorySize() const;
+    MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
+    MEDCOUPLING_EXPORT std::vector<RefCountObject *> getDirectChildren() const;
     MEDCOUPLING_EXPORT void setName(const char *name);
     MEDCOUPLING_EXPORT void copyStringInfoFrom(const DataArray& other) throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT void copyPartOfStringInfoFrom(const DataArray& other, const std::vector<int>& compoIds) throw(INTERP_KERNEL::Exception);
@@ -202,7 +203,7 @@ namespace ParaMEDMEM
     MEDCOUPLING_EXPORT void desallocate() throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT int getNumberOfTuples() const throw(INTERP_KERNEL::Exception) { return _info_on_compo.empty()?0:_mem.getNbOfElem()/getNumberOfComponents(); }
     MEDCOUPLING_EXPORT std::size_t getNbOfElems() const throw(INTERP_KERNEL::Exception) { return _mem.getNbOfElem(); }
-    MEDCOUPLING_EXPORT std::size_t getHeapMemorySize() const;
+    MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
     MEDCOUPLING_EXPORT double doubleValue() const throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT bool empty() const throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT DataArrayDouble *deepCpy() const throw(INTERP_KERNEL::Exception);
@@ -426,7 +427,7 @@ namespace ParaMEDMEM
     MEDCOUPLING_EXPORT void desallocate() throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT int getNumberOfTuples() const throw(INTERP_KERNEL::Exception) { return _info_on_compo.empty()?0:_mem.getNbOfElem()/getNumberOfComponents(); }
     MEDCOUPLING_EXPORT std::size_t getNbOfElems() const throw(INTERP_KERNEL::Exception) { return _mem.getNbOfElem(); }
-    MEDCOUPLING_EXPORT std::size_t getHeapMemorySize() const;
+    MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
     MEDCOUPLING_EXPORT int intValue() const throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT int getHashCode() const throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT bool empty() const throw(INTERP_KERNEL::Exception);
@@ -657,7 +658,7 @@ namespace ParaMEDMEM
     MEDCOUPLING_EXPORT void desallocate() throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT int getNumberOfTuples() const throw(INTERP_KERNEL::Exception) { return _info_on_compo.empty()?0:_mem.getNbOfElem()/getNumberOfComponents(); }
     MEDCOUPLING_EXPORT std::size_t getNbOfElems() const throw(INTERP_KERNEL::Exception) { return _mem.getNbOfElem(); }
-    MEDCOUPLING_EXPORT std::size_t getHeapMemorySize() const;
+    MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
     MEDCOUPLING_EXPORT int getHashCode() const throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT bool empty() const throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT void cpyFrom(const DataArrayChar& other) throw(INTERP_KERNEL::Exception);
index d363454bb77108e96ae37a6ab66a6d610f70d059..c9cb325c0e2960f54c254c790b94a974d89dfe2e 100644 (file)
@@ -60,10 +60,10 @@ void DataArrayChar::desallocate() throw(INTERP_KERNEL::Exception)
   _mem.destroy();
 }
 
-std::size_t DataArrayChar::getHeapMemorySize() const
+std::size_t DataArrayChar::getHeapMemorySizeWithoutChildren() const
 {
-  std::size_t sz=_mem.getNbOfElemAllocated();
-  return DataArray::getHeapMemorySize()+sz;
+  std::size_t sz(_mem.getNbOfElemAllocated());
+  return DataArray::getHeapMemorySizeWithoutChildren()+sz;
 }
 
 /*!
index 1615842b6dce8d4504489b985a2a1c302aeb8a17..a9b28d58582d0efbbd550ed593c7364462c1694f 100644 (file)
@@ -43,7 +43,7 @@ MEDCouplingMesh::MEDCouplingMesh(const MEDCouplingMesh& other):_name(other._name
 {
 }
 
-std::size_t MEDCouplingMesh::getHeapMemorySize() const
+std::size_t MEDCouplingMesh::getHeapMemorySizeWithoutChildren() const
 {
   return _name.capacity()+_description.capacity()+_time_unit.capacity();
 }
index af3d71d026a5a89056324108dae04eaaa08e13ed..f12406fabed464ac2a0ede2189bd1648346673d9 100644 (file)
@@ -54,7 +54,7 @@ namespace ParaMEDMEM
   class MEDCOUPLING_EXPORT MEDCouplingMesh : public RefCountObject, public TimeLabel
   {
   public:
-    std::size_t getHeapMemorySize() const;
+    std::size_t getHeapMemorySizeWithoutChildren() const;
     void setName(const char *name) { _name=name; }
     std::string getName() const { return _name; }
     void setDescription(const char *descr) { _description=descr; }
index 4e3c6580e604e0cf5c25c3fe3c8dafc13cdaaabe..436ab8d20c53ff213b8c9e5f7062cdfbd0141b88 100644 (file)
@@ -190,19 +190,20 @@ void MEDCouplingMultiFields::updateTime() const
       updateTimeWith(*(*it));
 }
 
-std::size_t MEDCouplingMultiFields::getHeapMemorySize() const
+std::size_t MEDCouplingMultiFields::getHeapMemorySizeWithoutChildren() const
 {
-  std::vector<int> tmp;
-  std::vector< std::vector<int> > tmp2;
-  std::vector<MEDCouplingMesh *> ms=getDifferentMeshes(tmp);
-  std::vector<DataArrayDouble *> arrs=getDifferentArrays(tmp2);
-  std::size_t ret=0;
-  for(std::vector<MEDCouplingMesh *>::const_iterator it=ms.begin();it!=ms.end();it++)
-    if(*it)
-      ret+=(*it)->getHeapMemorySize();
-  for(std::vector<DataArrayDouble *>::const_iterator it=arrs.begin();it!=arrs.end();it++)
-    if(*it)
-      ret+=(*it)->getHeapMemorySize();
+  return 0;
+}
+
+std::vector<RefCountObject *> MEDCouplingMultiFields::getDirectChildren() const
+{
+  std::vector<RefCountObject *> ret;
+  for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> >::const_iterator it=_fs.begin();it!=_fs.end();it++)
+    {
+      const MEDCouplingFieldDouble *curF(*it);
+      if(curF)
+        ret.push_back(const_cast<MEDCouplingFieldDouble *>(curF));
+    }
   return ret;
 }
 
index ad36e66279f0b78d83a9239d5329cb768d512fa4..d770576e225a90c670cde3523e9790f58d2b03aa 100644 (file)
@@ -59,7 +59,8 @@ namespace ParaMEDMEM
     virtual std::vector<DataArrayDouble *> getArrays() const throw(INTERP_KERNEL::Exception);
     virtual std::vector<DataArrayDouble *> getDifferentArrays(std::vector< std::vector<int> >& refs) const throw(INTERP_KERNEL::Exception);
     void updateTime() const;
-    std::size_t getHeapMemorySize() const;
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<RefCountObject *> getDirectChildren() const;
     void getTinySerializationInformation(std::vector<int>& tinyInfo, std::vector<double>& tinyInfo2, int& nbOfDiffMeshes, int& nbOfDiffArr) const;
     void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD,
                                const std::vector<MEDCouplingFieldTemplate *>& ft, const std::vector<MEDCouplingMesh *>& ms,
index 50ae9094ec203f0a39b328e8c79fd9b9b55d37fb..8c3fb4660b58f1087fe928c2fbe905fe45087009 100644 (file)
@@ -75,12 +75,17 @@ void MEDCouplingPointSet::updateTime() const
     }
 }
 
-std::size_t MEDCouplingPointSet::getHeapMemorySize() const
+std::size_t MEDCouplingPointSet::getHeapMemorySizeWithoutChildren() const
 {
-  std::size_t ret=0;
+  return MEDCouplingMesh::getHeapMemorySizeWithoutChildren();
+}
+
+std::vector<RefCountObject *> MEDCouplingPointSet::getDirectChildren() const
+{
+  std::vector<RefCountObject *> ret;
   if(_coords)
-    ret+=_coords->getHeapMemorySize();
-  return MEDCouplingMesh::getHeapMemorySize()+ret;
+    ret.push_back(const_cast<DataArrayDouble *>(_coords));
+  return ret;
 }
 
 void MEDCouplingPointSet::setCoords(const DataArrayDouble *coords)
index 00d9a33b50d54fc769082bdbb09f521502cccf5a..df12ac7b29da75be4f9dd039da3e574e35e19a7a 100644 (file)
@@ -52,7 +52,8 @@ namespace ParaMEDMEM
     ~MEDCouplingPointSet();
   public:
     void updateTime() const;
-    std::size_t getHeapMemorySize() const;
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<RefCountObject *> getDirectChildren() const;
     int getNumberOfNodes() const;
     int getSpaceDimension() const;
     void setCoords(const DataArrayDouble *coords);
index 7f9f493f699e17bb262483694325c10affc72de7..b2374b980bddca7ab85176de6c96def3a7bdd007 100644 (file)
@@ -21,6 +21,8 @@
 #include "MEDCouplingRefCountObject.hxx"
 #include "MED_version.h"
 
+#include <set>
+
 using namespace ParaMEDMEM;
 
 const char *ParaMEDMEM::MEDCouplingVersionStr()
@@ -85,6 +87,31 @@ RefCountObject& RefCountObject::operator=(const RefCountObject& other)
   return *this;
 }
 
+std::size_t RefCountObject::getHeapMemorySize() const
+{
+  std::size_t ret(getHeapMemorySizeWithoutChildren());
+  std::vector<RefCountObject *> v(getDirectChildren());
+  std::set<RefCountObject *> s1,s2(v.begin(),v.end());
+  while(!s2.empty())
+    {
+      std::set<RefCountObject *> s3;
+      for(std::set<RefCountObject *>::const_iterator it=s2.begin();it!=s2.end();it++)
+        {
+          if(s1.find(*it)==s1.end())
+            {
+              ret+=(*it)->getHeapMemorySizeWithoutChildren();
+              s1.insert(*it);
+              std::vector<RefCountObject *> v2((*it)->getDirectChildren());
+              for(std::vector<RefCountObject *>::const_iterator it2=v2.begin();it2!=v2.end();it2++)
+                if(s1.find(*it2)==s1.end())
+                  s3.insert(*it2);
+            }
+        }
+      s2=s3;
+    }
+  return ret;
+}
+
 bool RefCountObject::decrRef() const
 {
   bool ret=((--_cnt)==0);
index f5c99be4a7a80db2bcb86223896fbb6f3c596ad8..883f4599de2c0fa64c597f1a85cdfefc8983726d 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "MEDCoupling.hxx"
 
+#include <vector>
 #include <cstddef>
 
 namespace ParaMEDMEM
@@ -59,17 +60,19 @@ namespace ParaMEDMEM
   MEDCOUPLING_EXPORT bool MEDCouplingByteOrder();
   MEDCOUPLING_EXPORT const char *MEDCouplingByteOrderStr();
 
-  class MEDCOUPLING_EXPORT RefCountObject
+  class RefCountObject
   {
   protected:
     RefCountObject();
     RefCountObject(const RefCountObject& other);
   public:
-    bool decrRef() const;
-    void incrRef() const;
-    virtual std::size_t getHeapMemorySize() const = 0;
-    int getRCValue() const;
-    RefCountObject& operator=(const RefCountObject& other);
+    MEDCOUPLING_EXPORT bool decrRef() const;
+    MEDCOUPLING_EXPORT void incrRef() const;
+    MEDCOUPLING_EXPORT std::size_t getHeapMemorySize() const;
+    MEDCOUPLING_EXPORT virtual std::size_t getHeapMemorySizeWithoutChildren() const = 0;
+    MEDCOUPLING_EXPORT virtual std::vector<RefCountObject *> getDirectChildren() const = 0;
+    MEDCOUPLING_EXPORT int getRCValue() const;
+    MEDCOUPLING_EXPORT RefCountObject& operator=(const RefCountObject& other);
   protected:
     virtual ~RefCountObject();
   private:
index 2c92df2413901e1b4e860adb3e2751b7fcd20cfa..60b20c5eaeb1ce1b1976e71fd92fd4751f4d2202 100644 (file)
@@ -40,9 +40,9 @@ MEDCouplingStructuredMesh::~MEDCouplingStructuredMesh()
 {
 }
 
-std::size_t MEDCouplingStructuredMesh::getHeapMemorySize() const
+std::size_t MEDCouplingStructuredMesh::getHeapMemorySizeWithoutChildren() const
 {
-  return MEDCouplingMesh::getHeapMemorySize();
+  return MEDCouplingMesh::getHeapMemorySizeWithoutChildren();
 }
 
 void MEDCouplingStructuredMesh::copyTinyStringsFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception)
index a8cb2ef7c80d6ef2002ad6e45967e1e846edf1e3..004b728eb5cda5764356ad47f218078f36554e20 100644 (file)
@@ -41,7 +41,7 @@ namespace ParaMEDMEM
     static void GetPosFromId(int nodeId, int meshDim, const int *split, int *res);
     static INTERP_KERNEL::NormalizedCellType GetGeoTypeGivenMeshDimension(int meshDim) throw(INTERP_KERNEL::Exception);
     void getNodeIdsOfCell(int cellId, std::vector<int>& conn) const;
-    std::size_t getHeapMemorySize() const;
+    std::size_t getHeapMemorySizeWithoutChildren() const;
     void copyTinyStringsFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception);
     bool isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const throw(INTERP_KERNEL::Exception);
     //tools
index 818f4eb711f8fe6abf07eb6e5dc0546354ebc3ed..7bc366262a572c0f1b3f976d1eec31338c251893 100644 (file)
@@ -93,11 +93,17 @@ void MEDCouplingTimeDiscretization::updateTime() const
     updateTimeWith(*_array);
 }
 
-std::size_t MEDCouplingTimeDiscretization::getHeapMemorySize() const
+std::size_t MEDCouplingTimeDiscretization::getHeapMemorySizeWithoutChildren() const
 {
-  std::size_t ret=_time_unit.capacity();
+  std::size_t ret(_time_unit.capacity());
+  return ret;
+}
+
+std::vector<RefCountObject *> MEDCouplingTimeDiscretization::getDirectChildren() const
+{
+  std::vector<RefCountObject *> ret;
   if(_array)
-    ret+=_array->getHeapMemorySize();
+    ret.push_back(const_cast<DataArrayDouble *>(_array));
   return ret;
 }
 
@@ -2208,12 +2214,17 @@ void MEDCouplingTwoTimeSteps::synchronizeTimeWith(const MEDCouplingMesh *mesh) t
   _time_unit=tUnit;
 }
 
-std::size_t MEDCouplingTwoTimeSteps::getHeapMemorySize() const
+std::size_t MEDCouplingTwoTimeSteps::getHeapMemorySizeWithoutChildren() const
 {
-  std::size_t ret=0;
+  return MEDCouplingTimeDiscretization::getHeapMemorySizeWithoutChildren();
+}
+
+std::vector<RefCountObject *> MEDCouplingTwoTimeSteps::getDirectChildren() const
+{
+  std::vector<RefCountObject *> ret(MEDCouplingTimeDiscretization::getDirectChildren());
   if(_end_array)
-    ret+=_end_array->getHeapMemorySize();
-  return MEDCouplingTimeDiscretization::getHeapMemorySize()+ret;
+    ret.push_back(const_cast<DataArrayDouble *>(_end_array));
+  return ret;
 }
 
 void MEDCouplingTwoTimeSteps::copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other) throw(INTERP_KERNEL::Exception)
index 8cdbbe957e08eba584c4ebf5d3e4c94c71da2ed4..15641eabfa80f4ec4852a4f0697963ccbe329141 100644 (file)
@@ -41,7 +41,8 @@ namespace ParaMEDMEM
     MEDCouplingTimeDiscretization(const MEDCouplingTimeDiscretization& other, bool deepCpy);
   public:
     void updateTime() const;
-    virtual std::size_t getHeapMemorySize() const;
+    virtual std::size_t getHeapMemorySizeWithoutChildren() const;
+    virtual std::vector<RefCountObject *> getDirectChildren() const;
     static MEDCouplingTimeDiscretization *New(TypeOfTimeDiscretization type) throw(INTERP_KERNEL::Exception);
     void setTimeUnit(const char *unit) { _time_unit=unit; }
     const char *getTimeUnit() const { return _time_unit.c_str(); }
@@ -367,7 +368,8 @@ namespace ParaMEDMEM
   public:
     void updateTime() const;
     void synchronizeTimeWith(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception);
-    std::size_t getHeapMemorySize() const;
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<RefCountObject *> getDirectChildren() const;
     void copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other) throw(INTERP_KERNEL::Exception);
     void copyTinyStringsFrom(const MEDCouplingTimeDiscretization& other) throw(INTERP_KERNEL::Exception);
     const DataArrayDouble *getEndArray() const throw(INTERP_KERNEL::Exception);
index 70fba21d9750110f3e1a569f6b916e42278c20fc..53dd0d55fa086b8c14355b51d4e0d3719d99b186 100644 (file)
@@ -115,14 +115,20 @@ void MEDCouplingUMesh::shallowCopyConnectivityFrom(const MEDCouplingPointSet *ot
   setConnectivity(otherC2->getNodalConnectivity(),otherC2->getNodalConnectivityIndex(),true);
 }
 
-std::size_t MEDCouplingUMesh::getHeapMemorySize() const
+std::size_t MEDCouplingUMesh::getHeapMemorySizeWithoutChildren() const
 {
-  std::size_t ret=0;
+  std::size_t ret(MEDCouplingPointSet::getHeapMemorySizeWithoutChildren());
+  return ret;
+}
+
+std::vector<RefCountObject *> MEDCouplingUMesh::getDirectChildren() const
+{
+  std::vector<RefCountObject *> ret(MEDCouplingPointSet::getDirectChildren());
   if(_nodal_connec)
-    ret+=_nodal_connec->getHeapMemorySize();
+    ret.push_back(const_cast<DataArrayInt *>(_nodal_connec));
   if(_nodal_connec_index)
-    ret+=_nodal_connec_index->getHeapMemorySize();
-  return MEDCouplingPointSet::getHeapMemorySize()+ret;
+    ret.push_back(const_cast<DataArrayInt *>(_nodal_connec_index));
+  return ret;
 }
 
 void MEDCouplingUMesh::updateTime() const
index 4941812c21a3f4a8a0be2f4f58965d4ded45fa86..4c75c0af561afae9574c3868bab2f91a1196685e 100644 (file)
@@ -46,7 +46,8 @@ namespace ParaMEDMEM
     MEDCOUPLING_EXPORT MEDCouplingPointSet *deepCpyConnectivityOnly() const throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT void shallowCopyConnectivityFrom(const MEDCouplingPointSet *other) throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT void updateTime() const;
-    MEDCOUPLING_EXPORT std::size_t getHeapMemorySize() const;
+    MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
+    MEDCOUPLING_EXPORT std::vector<RefCountObject *> getDirectChildren() const;
     MEDCOUPLING_EXPORT MEDCouplingMeshType getType() const { return UNSTRUCTURED; }
     MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const;
index 321aefa8807dc1cbcfb5102eb082963b5ccf65c0..2c2646424aa9ab9baeecc7c4bfcc2ddbdf6a5aa8 100644 (file)
@@ -48,16 +48,22 @@ MEDFileData *MEDFileData::deepCpy() const throw(INTERP_KERNEL::Exception)
   return ret.retn();
 }
 
-std::size_t MEDFileData::getHeapMemorySize() const
+std::size_t MEDFileData::getHeapMemorySizeWithoutChildren() const
 {
-  std::size_t ret=0;
+  return 0;
+}
+
+std::vector<RefCountObject *> MEDFileData::getDirectChildren() const
+{
+  std::vector<RefCountObject *> ret;
   if((const MEDFileFields *)_fields)
-    ret+=_fields->getHeapMemorySize();
+    ret.push_back(const_cast<MEDFileFields *>((const MEDFileFields *)_fields));
   if((const MEDFileMeshes *)_meshes)
-    ret+=_meshes->getHeapMemorySize();
+    ret.push_back(const_cast<MEDFileMeshes *>((const MEDFileMeshes *)_meshes));
   if((const MEDFileParameters *)_params)
-    ret+=_params->getHeapMemorySize();
+    ret.push_back(const_cast<MEDFileParameters *>((const MEDFileParameters *)_params));
   return ret;
+  
 }
 
 MEDFileFields *MEDFileData::getFields() const
index 2eb38e3020f3a17630a6188df58b3895bb1094af..31411500e704cbd378fa885358ec0b6d089b8014 100644 (file)
@@ -37,7 +37,8 @@ namespace ParaMEDMEM
     static MEDFileData *New(const char *fileName) throw(INTERP_KERNEL::Exception);
     static MEDFileData *New();
     MEDFileData *deepCpy() const throw(INTERP_KERNEL::Exception);
-    std::size_t getHeapMemorySize() const;
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<RefCountObject *> getDirectChildren() const;
     MEDFileFields *getFields() const;
     MEDFileMeshes *getMeshes() const;
     MEDFileParameters *getParams() const;
index b40a58df65bf50e09ffd5adf0046f9c091a6be28..0a712f93c38839295f102777fbceddc364eebef9 100644 (file)
@@ -109,11 +109,16 @@ MEDFileFieldLoc *MEDFileFieldLoc::deepCpy() const
   return new MEDFileFieldLoc(*this);
 }
 
-std::size_t MEDFileFieldLoc::getHeapMemorySize() const
+std::size_t MEDFileFieldLoc::getHeapMemorySizeWithoutChildren() const
 {
   return (_ref_coo.capacity()+_gs_coo.capacity()+_w.capacity())*sizeof(double)+_name.capacity();
 }
 
+std::vector<RefCountObject *> MEDFileFieldLoc::getDirectChildren() const
+{
+  return std::vector<RefCountObject *>();
+}
+
 void MEDFileFieldLoc::simpleRepr(std::ostream& oss) const
 {
   static const char OFF7[]="\n    ";
@@ -402,11 +407,16 @@ MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(const
   return new MEDFileFieldPerMeshPerTypePerDisc(other);
 }
 
-std::size_t MEDFileFieldPerMeshPerTypePerDisc::getHeapMemorySize() const
+std::size_t MEDFileFieldPerMeshPerTypePerDisc::getHeapMemorySizeWithoutChildren() const
 {
   return _profile.capacity()+_localization.capacity()+5*sizeof(int);
 }
 
+std::vector<RefCountObject *> MEDFileFieldPerMeshPerTypePerDisc::getDirectChildren() const
+{
+  return std::vector<RefCountObject *>();
+}
+
 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::deepCpy(MEDFileFieldPerMeshPerType *father) const throw(INTERP_KERNEL::Exception)
 {
   MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> ret=new MEDFileFieldPerMeshPerTypePerDisc(*this);
@@ -968,11 +978,20 @@ MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh
   return new MEDFileFieldPerMeshPerType(fath,geoType);
 }
 
-std::size_t MEDFileFieldPerMeshPerType::getHeapMemorySize() const
+std::size_t MEDFileFieldPerMeshPerType::getHeapMemorySizeWithoutChildren() const
+{
+  return _field_pm_pt_pd.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc>);
+}
+
+std::vector<RefCountObject *> MEDFileFieldPerMeshPerType::getDirectChildren() const
 {
-  std::size_t ret=_field_pm_pt_pd.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc>);
+  std::vector<RefCountObject *> ret;
   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
-    ret+=(*it)->getHeapMemorySize();
+    {
+      const MEDFileFieldPerMeshPerTypePerDisc *cur(*it);
+      if(cur)
+        ret.push_back(const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(cur));
+    }
   return ret;
 }
 
@@ -1521,12 +1540,20 @@ MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *
   return new MEDFileFieldPerMesh(fath,mesh);
 }
 
-std::size_t MEDFileFieldPerMesh::getHeapMemorySize() const
+std::size_t MEDFileFieldPerMesh::getHeapMemorySizeWithoutChildren() const
 {
-  std::size_t ret=_mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType >);
+  return _mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType >);
+}
+
+std::vector<RefCountObject *> MEDFileFieldPerMesh::getDirectChildren() const
+{
+  std::vector<RefCountObject *> ret;
   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
-    if((const MEDFileFieldPerMeshPerType *)*it)
-      ret+=(*it)->getHeapMemorySize();
+    {
+      const MEDFileFieldPerMeshPerType *cur(*it);
+      if(cur)
+        ret.push_back(const_cast<MEDFileFieldPerMeshPerType *>(cur));
+    }
   return ret;
 }
 
@@ -2502,13 +2529,26 @@ MEDFileFieldGlobs *MEDFileFieldGlobs::New()
   return new MEDFileFieldGlobs;
 }
 
-std::size_t MEDFileFieldGlobs::getHeapMemorySize() const
+std::size_t MEDFileFieldGlobs::getHeapMemorySizeWithoutChildren() const
 {
-  std::size_t ret=_file_name.capacity()+_pfls.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<DataArrayInt>)+_locs.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>);
-  for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
-    ret+=(*it)->getHeapMemorySize();
+  return _file_name.capacity()+_pfls.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<DataArrayInt>)+_locs.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>);
+}
+
+std::vector<RefCountObject *> MEDFileFieldGlobs::getDirectChildren() const
+{
+  std::vector<RefCountObject *> ret;
+  for(std::vector< MEDCouplingAutoRefCountObjectPtr< DataArrayInt > >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
+    {
+      const DataArrayInt *cur(*it);
+      if(cur)
+        ret.push_back(const_cast<DataArrayInt *>(cur));
+    }
   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
-    ret+=(*it)->getHeapMemorySize();
+    {
+      const MEDFileFieldLoc *cur(*it);
+      if(cur)
+        ret.push_back(const_cast<MEDFileFieldLoc *>(cur));
+    }
   return ret;
 }
 
@@ -2958,11 +2998,16 @@ MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New()
 {
 }
 
-std::size_t MEDFileFieldGlobsReal::getHeapMemorySize() const
+std::size_t MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren() const
+{
+  return 0;
+}
+
+std::vector<RefCountObject *> MEDFileFieldGlobsReal::getDirectChildren() const
 {
-  std::size_t ret=0;
+  std::vector<RefCountObject *> ret;
   if((const MEDFileFieldGlobs *)_globals)
-    ret+=_globals->getHeapMemorySize();
+    ret.push_back(const_cast<MEDFileFieldGlobs *>((const MEDFileFieldGlobs *)_globals));
   return ret;
 }
 
@@ -4187,13 +4232,22 @@ void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays() throw(INTERP_KERNEL::Excep
     }
 }
 
-std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySize() const
+std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySizeWithoutChildren() const
 {
-  std::size_t ret=_dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh >);
+  return _dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh >);
+}
+
+std::vector<RefCountObject *> MEDFileAnyTypeField1TSWithoutSDA::getDirectChildren() const
+{
+  std::vector<RefCountObject *> ret;
   if(getUndergroundDataArray())
-    ret+=getUndergroundDataArray()->getHeapMemorySize();
+    ret.push_back(const_cast<DataArray *>(getUndergroundDataArray()));
   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
-    ret+=(*it)->getHeapMemorySize();
+    {
+      const MEDFileFieldPerMesh *cur(*it);
+      if(cur)
+        ret.push_back(const_cast<MEDFileFieldPerMesh *>(cur));
+    }
   return ret;
 }
 
@@ -5564,12 +5618,17 @@ void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exc
   contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
 }
 
-std::size_t MEDFileAnyTypeField1TS::getHeapMemorySize() const
+std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
+{
+  return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
+}
+
+std::vector<RefCountObject *> MEDFileAnyTypeField1TS::getDirectChildren() const
 {
-  std::size_t ret=0;
+  std::vector<RefCountObject *> ret(MEDFileFieldGlobsReal::getDirectChildren());
   if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
-    ret+=_content->getHeapMemorySize();
-  return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
+    ret.push_back(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>((const MEDFileAnyTypeField1TSWithoutSDA *)_content));
+  return ret;
 }
 
 /*!
@@ -6663,14 +6722,23 @@ catch(INTERP_KERNEL::Exception& e)
   throw e;
 }
 
-std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySize() const
+std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
 {
-  std::size_t ret=_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA>);
+  std::size_t ret(_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA>));
   for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
     ret+=(*it).capacity();
+  return ret;
+}
+
+std::vector<RefCountObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildren() const
+{
+  std::vector<RefCountObject *> ret;
   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
-    if((const MEDFileAnyTypeField1TSWithoutSDA *)(*it))
-      ret+=(*it)->getHeapMemorySize();
+    {
+      const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
+      if(cur)
+        ret.push_back(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(cur));
+    }
   return ret;
 }
 
@@ -8116,12 +8184,17 @@ std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
   return oss.str();
 }
 
-std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySize() const
+std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
+{
+  return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
+}
+
+std::vector<RefCountObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildren() const
 {
-  std::size_t ret=0;
-  if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)_content)
-    ret+=_content->getHeapMemorySize();
-  return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
+  std::vector<RefCountObject *> ret(MEDFileFieldGlobsReal::getDirectChildren());
+  if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
+    ret.push_back(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content));
+  return ret;
 }
 
 /*!
@@ -9283,13 +9356,23 @@ MEDFileFields *MEDFileFields::New(const char *fileName, bool loadAll) throw(INTE
   return new MEDFileFields(fileName,loadAll);
 }
 
-std::size_t MEDFileFields::getHeapMemorySize() const
+std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
+{
+  std::size_t ret(MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren());
+  ret+=_fields.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
+  return ret;
+}
+
+std::vector<RefCountObject *> MEDFileFields::getDirectChildren() const
 {
-  std::size_t ret=_fields.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
+  std::vector<RefCountObject *> ret;
   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
-    if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it)
-      ret+=(*it)->getHeapMemorySize();
-  return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
+    {
+      const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
+      if(cur)
+        ret.push_back(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
+    }
+  return ret;
 }
 
 MEDFileFields *MEDFileFields::deepCpy() const throw(INTERP_KERNEL::Exception)
index 9cb29b6fb60f546e67685e5f720ce00896849690..38a6ae1e58ff7cd9f74659c339c4e93ddd54db37 100644 (file)
@@ -55,7 +55,8 @@ namespace ParaMEDMEM
     static MEDFileFieldLoc *New(med_idt fid, const char *locName);
     static MEDFileFieldLoc *New(med_idt fid, int id);
     static MEDFileFieldLoc *New(const char *locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w);
-    std::size_t getHeapMemorySize() const;
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<RefCountObject *> getDirectChildren() const;
     MEDFileFieldLoc *deepCpy() const;
     int MEDLOADER_EXPORT getNbOfGaussPtPerCell() const { return _nb_gauss_pt; }
     void MEDLOADER_EXPORT writeLL(med_idt fid) const;
@@ -97,7 +98,8 @@ namespace ParaMEDMEM
     static MEDFileFieldPerMeshPerTypePerDisc *NewOnRead(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt) throw(INTERP_KERNEL::Exception);
     static MEDFileFieldPerMeshPerTypePerDisc *New(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId);
     static MEDFileFieldPerMeshPerTypePerDisc *New(const MEDFileFieldPerMeshPerTypePerDisc& other);
-    std::size_t getHeapMemorySize() const;
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<RefCountObject *> getDirectChildren() const;
     MEDFileFieldPerMeshPerTypePerDisc *deepCpy(MEDFileFieldPerMeshPerType *father) const throw(INTERP_KERNEL::Exception);
     void assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception);
     void assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arrr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception);
@@ -172,7 +174,8 @@ namespace ParaMEDMEM
   public:
     static MEDFileFieldPerMeshPerType *New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception);
     static MEDFileFieldPerMeshPerType *NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception);
-    std::size_t getHeapMemorySize() const;
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<RefCountObject *> getDirectChildren() const;
     MEDFileFieldPerMeshPerType *deepCpy(MEDFileFieldPerMesh *father) const throw(INTERP_KERNEL::Exception);
     void assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception);
     void assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception);
@@ -227,7 +230,8 @@ namespace ParaMEDMEM
   public:
     static MEDFileFieldPerMesh *New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh);
     static MEDFileFieldPerMesh *NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception);
-    std::size_t getHeapMemorySize() const;
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<RefCountObject *> getDirectChildren() const;
     MEDFileFieldPerMesh *deepCpy(MEDFileAnyTypeField1TSWithoutSDA *father) const throw(INTERP_KERNEL::Exception);
     void simpleRepr(int bkOffset,std::ostream& oss, int id) const;
     void copyTinyInfoFrom(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception);
@@ -300,7 +304,8 @@ namespace ParaMEDMEM
   public:
     static MEDFileFieldGlobs *New(const char *fname);
     static MEDFileFieldGlobs *New();
-    std::size_t getHeapMemorySize() const;
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<RefCountObject *> getDirectChildren() const;
     MEDFileFieldGlobs *deepCpy() const throw(INTERP_KERNEL::Exception);
     MEDFileFieldGlobs *shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const throw(INTERP_KERNEL::Exception);
     MEDFileFieldGlobs *deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const throw(INTERP_KERNEL::Exception);
@@ -360,7 +365,8 @@ namespace ParaMEDMEM
   public:
     MEDFileFieldGlobsReal(const char *fname);
     MEDFileFieldGlobsReal();
-    std::size_t getHeapMemorySize() const;
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<RefCountObject *> getDirectChildren() const;
     void simpleReprGlobs(std::ostream& oss) const;
     void resetContent();
     void shallowCpyGlobs(const MEDFileFieldGlobsReal& other);
@@ -482,7 +488,8 @@ namespace ParaMEDMEM
     const std::vector<std::string>& getInfo() const;
     std::vector<std::string>& getInfo();
     void setInfo(const std::vector<std::string>& infos) throw(INTERP_KERNEL::Exception);
-    std::size_t getHeapMemorySize() const;
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<RefCountObject *> getDirectChildren() const;
     int copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception);
     void setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception);
     void setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception);
@@ -666,7 +673,8 @@ namespace ParaMEDMEM
     void setProfileNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newPflName, bool forceRenameOnGlob=false) throw(INTERP_KERNEL::Exception);
     //! underground method see MEDFileField1TSWithoutSDA::setLocNameOnLeaf
     void setLocNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newLocName, bool forceRenameOnGlob=false) throw(INTERP_KERNEL::Exception);
-    std::size_t getHeapMemorySize() const;
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<RefCountObject *> getDirectChildren() const;
     std::vector<std::string> getPflsReallyUsed() const;
     std::vector<std::string> getLocsReallyUsed() const;
     std::vector<std::string> getPflsReallyUsedMulti() const;
@@ -774,7 +782,8 @@ namespace ParaMEDMEM
     MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll) throw(INTERP_KERNEL::Exception);
     MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll) throw(INTERP_KERNEL::Exception);
   public:
-    std::size_t getHeapMemorySize() const;
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<RefCountObject *> getDirectChildren() const;
     virtual MEDFileAnyTypeFieldMultiTSWithoutSDA *deepCpy() const throw(INTERP_KERNEL::Exception);
     virtual std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > splitComponents() const throw(INTERP_KERNEL::Exception);
     virtual std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > splitDiscretizations() const throw(INTERP_KERNEL::Exception);
@@ -904,7 +913,8 @@ namespace ParaMEDMEM
     void unloadArrays() throw(INTERP_KERNEL::Exception);
     void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
     void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception);
-    std::size_t getHeapMemorySize() const;
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<RefCountObject *> getDirectChildren() const;
     virtual MEDFileAnyTypeFieldMultiTS *deepCpy() const throw(INTERP_KERNEL::Exception);
     std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > splitComponents() const throw(INTERP_KERNEL::Exception);
     std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > splitDiscretizations() const throw(INTERP_KERNEL::Exception);
@@ -1064,7 +1074,8 @@ std::vector< std::vector<DataArrayDouble *> > getFieldSplitedByType2(int iterati
   public:
     static MEDFileFields *New();
     static MEDFileFields *New(const char *fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception);
-    std::size_t getHeapMemorySize() const;
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<RefCountObject *> getDirectChildren() const;
     MEDFileFields *deepCpy() const throw(INTERP_KERNEL::Exception);
     MEDFileFields *shallowCpy() const throw(INTERP_KERNEL::Exception);
     void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
index f0177647dfe524d6c1fdb090ffc2567e87f47e19..21f86e4523e51f697c88e3c4e6acbe6d84dcf6a1 100644 (file)
@@ -36,7 +36,7 @@ MEDFileMeshStruct *MEDFileMeshStruct::New(const MEDFileMesh *mesh)
   return new MEDFileMeshStruct(mesh);
 }
 
-std::size_t MEDFileMeshStruct::getHeapMemorySize() const
+std::size_t MEDFileMeshStruct::getHeapMemorySizeWithoutChildren() const
 {
   std::size_t ret(0);
   for(std::vector< std::vector<int> >::const_iterator it0=_geo_types_distrib.begin();it0!=_geo_types_distrib.end();it0++)
@@ -45,6 +45,11 @@ std::size_t MEDFileMeshStruct::getHeapMemorySize() const
   return ret;
 }
 
+std::vector<RefCountObject *> MEDFileMeshStruct::getDirectChildren() const
+{
+  return std::vector<RefCountObject *>();
+}
+
 MEDFileMeshStruct::MEDFileMeshStruct(const MEDFileMesh *mesh):_mesh(mesh)
 {
   std::vector<int> levs=mesh->getNonEmptyLevels();
@@ -104,11 +109,16 @@ int MEDFileMeshStruct::getNumberOfGeoTypesInLev(int relativeLev) const throw(INT
 
 //=
 
-std::size_t MEDMeshMultiLev::getHeapMemorySize() const
+std::size_t MEDMeshMultiLev::getHeapMemorySizeWithoutChildren() const
 {
   return 0;
 }
 
+std::vector<RefCountObject *> MEDMeshMultiLev::getDirectChildren() const
+{
+  return std::vector<RefCountObject *>();
+}
+
 MEDMeshMultiLev *MEDMeshMultiLev::New(const MEDFileMesh *m, const std::vector<int>& levs) throw(INTERP_KERNEL::Exception)
 {
   if(!m)
@@ -1159,13 +1169,18 @@ MEDFileField1TSStructItem2 MEDFileField1TSStructItem2::BuildAggregationOf(const
     }
 }
 
-std::size_t MEDFileField1TSStructItem2::getHeapMemorySize() const
+std::size_t MEDFileField1TSStructItem2::getHeapMemorySizeWithoutChildren() const
 {
-  std::size_t ret(0);
+  std::size_t ret(_loc.capacity());
+  return ret;
+}
+
+std::vector<RefCountObject *> MEDFileField1TSStructItem2::getDirectChildren() const
+{
+  std::vector<RefCountObject *> ret;
   const DataArrayInt *pfl(_pfl);
   if(pfl)
-    ret+=pfl->getHeapMemorySize();
-  ret+=_loc.capacity();
+    ret.push_back(const_cast<DataArrayInt *>(pfl));
   return ret;
 }
 
@@ -1371,12 +1386,17 @@ const MEDFileField1TSStructItem2& MEDFileField1TSStructItem::operator[](std::siz
   return _items[i];
 }
 
-std::size_t MEDFileField1TSStructItem::getHeapMemorySize() const
+std::size_t MEDFileField1TSStructItem::getHeapMemorySizeWithoutChildren() const
 {
-  std::size_t ret(0);
+  std::size_t ret(_items.size()*sizeof(MEDFileField1TSStructItem2));
+  return ret;
+}
+
+std::vector<RefCountObject *> MEDFileField1TSStructItem::getDirectChildren() const
+{
+  std::vector<RefCountObject *> ret;
   for(std::vector< MEDFileField1TSStructItem2 >::const_iterator it=_items.begin();it!=_items.end();it++)
-    ret+=(*it).getHeapMemorySize();
-  ret+=_items.size()*sizeof(MEDFileField1TSStructItem2);
+    ret.push_back(const_cast<MEDFileField1TSStructItem2 *>(&(*it)));
   return ret;
 }
 
@@ -1524,12 +1544,17 @@ bool MEDFileField1TSStruct::isCompatibleWithNodesDiscr(const MEDFileAnyTypeField
     return _already_checked[0].isNodeSupportEqual(other1,other);
 }
 
-std::size_t MEDFileField1TSStruct::getHeapMemorySize() const
+std::size_t MEDFileField1TSStruct::getHeapMemorySizeWithoutChildren() const
 {
-  std::size_t ret(0);
+  std::size_t ret(_already_checked.capacity()*sizeof(MEDFileField1TSStructItem));
+  return ret;
+}
+
+std::vector<RefCountObject *> MEDFileField1TSStruct::getDirectChildren() const
+{
+  std::vector<RefCountObject *> ret;
   for(std::vector<MEDFileField1TSStructItem>::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++)
-    ret+=(*it).getHeapMemorySize();
-  ret+=_already_checked.capacity()*sizeof(MEDFileField1TSStructItem);
+    ret.push_back(const_cast<MEDFileField1TSStructItem *>(&(*it)));
   return ret;
 }
 
@@ -1644,19 +1669,24 @@ MEDFileFastCellSupportComparator::MEDFileFastCellSupportComparator(const MEDFile
     }
 }
 
-std::size_t MEDFileFastCellSupportComparator::getHeapMemorySize() const
+std::size_t MEDFileFastCellSupportComparator::getHeapMemorySizeWithoutChildren() const
 {
-  std::size_t ret(0);
+  std::size_t ret(_f1ts_cmps.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSStruct>));
+  return ret;
+}
+
+std::vector<RefCountObject *> MEDFileFastCellSupportComparator::getDirectChildren() const
+{
+  std::vector<RefCountObject *> ret;
   const MEDFileMeshStruct *mst(_mesh_comp);
   if(mst)
-    ret+=mst->getHeapMemorySize();
+    ret.push_back(const_cast<MEDFileMeshStruct *>(mst));
   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSStruct> >::const_iterator it=_f1ts_cmps.begin();it!=_f1ts_cmps.end();it++)
     {
       const MEDFileField1TSStruct *cur(*it);
       if(cur)
-        ret+=cur->getHeapMemorySize()+sizeof(MEDFileField1TSStruct);
+        ret.push_back(const_cast<MEDFileField1TSStruct *>(cur));
     }
-  ret+=_f1ts_cmps.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSStruct>);
   return ret;
 }
 
index 1201d8f5929b35cc2a3831c69d67aee49ae94007..9525e403ab3a93e5f2847335ecc83657b047af72 100644 (file)
@@ -49,7 +49,8 @@ namespace ParaMEDMEM
   {
   public:
     MEDLOADER_EXPORT static MEDFileMeshStruct *New(const MEDFileMesh *mesh);
-    std::size_t getHeapMemorySize() const;
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<RefCountObject *> getDirectChildren() const;
     const MEDFileMesh *getTheMesh() const { return _mesh; }
     int getNumberOfNodes() const { return _nb_nodes; }
     int getNumberOfElemsOfGeoType(INTERP_KERNEL::NormalizedCellType t) const throw(INTERP_KERNEL::Exception);
@@ -70,7 +71,8 @@ namespace ParaMEDMEM
   class MEDMeshMultiLev : public RefCountObject
   {
   public:
-    std::size_t getHeapMemorySize() const;
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<RefCountObject *> getDirectChildren() const;
   public:
     static MEDMeshMultiLev *New(const MEDFileMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities) throw(INTERP_KERNEL::Exception);
     static MEDMeshMultiLev *New(const MEDFileMesh *m, const std::vector<int>& levs) throw(INTERP_KERNEL::Exception);
@@ -174,7 +176,8 @@ namespace ParaMEDMEM
     void checkWithMeshStructForGaussNE(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) throw(INTERP_KERNEL::Exception);
     void checkWithMeshStructForGaussPT(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) throw(INTERP_KERNEL::Exception);
     //
-    MEDLOADER_EXPORT std::size_t getHeapMemorySize() const;
+    MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
+    MEDLOADER_EXPORT std::vector<RefCountObject *> getDirectChildren() const;
     //
     const DataArrayInt *getPfl(const MEDFileFieldGlobsReal *globs) const;
     INTERP_KERNEL::NormalizedCellType getGeo() const { return _geo_type; }
@@ -206,7 +209,8 @@ namespace ParaMEDMEM
     MEDFileField1TSStructItem(TypeOfField a, const std::vector< MEDFileField1TSStructItem2 >& b);
     void checkWithMeshStruct(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) throw(INTERP_KERNEL::Exception);
     bool operator==(const MEDFileField1TSStructItem& other) const throw(INTERP_KERNEL::Exception);
-    MEDLOADER_EXPORT std::size_t getHeapMemorySize() const;
+    MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
+    MEDLOADER_EXPORT std::vector<RefCountObject *> getDirectChildren() const;
     bool isEntityCell() const;
     bool isComputed() const { return _computed; }
     TypeOfField getType() const { return _type; }
@@ -231,7 +235,8 @@ namespace ParaMEDMEM
   public:
     static MEDFileField1TSStruct *New(const MEDFileAnyTypeField1TS *ref, MEDFileMeshStruct *mst) throw(INTERP_KERNEL::Exception);
     void checkWithMeshStruct(MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) throw(INTERP_KERNEL::Exception);
-    std::size_t getHeapMemorySize() const;
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<RefCountObject *> getDirectChildren() const;
     bool isEqualConsideringThePast(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *mst) const throw(INTERP_KERNEL::Exception);
     bool isSupportSameAs(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *meshSt) throw(INTERP_KERNEL::Exception);
     bool isCompatibleWithNodesDiscr(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *meshSt) throw(INTERP_KERNEL::Exception);
@@ -253,7 +258,8 @@ namespace ParaMEDMEM
     MEDLOADER_EXPORT bool isDataSetSupportEqualToThePreviousOne(int timeStepId, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception);
     bool isEqual(const MEDFileAnyTypeFieldMultiTS *other) throw(INTERP_KERNEL::Exception);
     bool isCompatibleWithNodesDiscr(const MEDFileAnyTypeFieldMultiTS *other) throw(INTERP_KERNEL::Exception);
-    std::size_t getHeapMemorySize() const;
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<RefCountObject *> getDirectChildren() const;
   private:
     MEDFileFastCellSupportComparator(const MEDFileMeshStruct *m, const MEDFileAnyTypeFieldMultiTS *ref);
   private:
index 0eeecf37da7966b3bb2f96ae401a98cff61b67c8..d6f11e227fbdc37618a0fb3075cdc5221f2f889c 100644 (file)
@@ -40,9 +40,9 @@ MEDFileMesh::MEDFileMesh():_order(-1),_iteration(-1),_time(0.),_univ_wr_status(t
 {
 }
 
-std::size_t MEDFileMesh::getHeapMemorySize() const
+std::size_t MEDFileMesh::getHeapMemorySizeWithoutChildren() const
 {
-  std::size_t ret=_dt_unit.capacity()+_name.capacity()+_univ_name.capacity()+_desc_name.capacity();
+  std::size_t ret(_dt_unit.capacity()+_name.capacity()+_univ_name.capacity()+_desc_name.capacity());
   for(std::map<std::string, std::vector<std::string> >::const_iterator it=_groups.begin();it!=_groups.end();it++)
     {
       ret+=(*it).first.capacity()+(*it).second.capacity()*sizeof(std::string);
@@ -54,6 +54,11 @@ std::size_t MEDFileMesh::getHeapMemorySize() const
   return ret;
 }
 
+std::vector<RefCountObject *> MEDFileMesh::getDirectChildren() const
+{
+  return std::vector<RefCountObject *>();
+}
+
 /*!
  * Returns a new MEDFileMesh holding the mesh data that has been read from a given MED
  * file. The first mesh in the file is loaded.
@@ -1920,23 +1925,29 @@ MEDFileUMesh *MEDFileUMesh::New()
   return new MEDFileUMesh;
 }
 
-std::size_t MEDFileUMesh::getHeapMemorySize() const
+std::size_t MEDFileUMesh::getHeapMemorySizeWithoutChildren() const
 {
-  std::size_t ret=MEDFileMesh::getHeapMemorySize();
+  std::size_t ret(MEDFileMesh::getHeapMemorySizeWithoutChildren());
+  ret+=_ms.capacity()*(sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1>));
+  return ret;
+}
+
+std::vector<RefCountObject *> MEDFileUMesh::getDirectChildren() const
+{
+  std::vector<RefCountObject *> ret(MEDFileMesh::getDirectChildren());
   if((const DataArrayDouble*)_coords)
-    ret+=_coords->getHeapMemorySize();
+    ret.push_back(const_cast<DataArrayDouble *>((const DataArrayDouble*)_coords));
   if((const DataArrayInt *)_fam_coords)
-    ret+=_fam_coords->getHeapMemorySize();
+    ret.push_back(const_cast<DataArrayInt *>((const DataArrayInt *)_fam_coords));
   if((const DataArrayInt *)_num_coords)
-    ret+=_num_coords->getHeapMemorySize();
+    ret.push_back(const_cast<DataArrayInt *>((const DataArrayInt *)_num_coords));
   if((const DataArrayInt *)_rev_num_coords)
-    ret+=_rev_num_coords->getHeapMemorySize();
+    ret.push_back(const_cast<DataArrayInt *>((const DataArrayInt *)_rev_num_coords));
   if((const DataArrayAsciiChar *)_name_coords)
-    ret+=_name_coords->getHeapMemorySize();
-  ret+=_ms.capacity()*(sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1>));
+    ret.push_back(const_cast<DataArrayAsciiChar *>((const DataArrayAsciiChar *)_name_coords));
   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> >::const_iterator it=_ms.begin();it!=_ms.end();it++)
     if((const MEDFileUMeshSplitL1*) *it)
-      ret+=(*it)->getHeapMemorySize();
+      ret.push_back(const_cast<MEDFileUMeshSplitL1 *>((const MEDFileUMeshSplitL1*) *it));
   return ret;
 }
 
@@ -3801,21 +3812,26 @@ void MEDFileUMesh::computeRevNum() const
     }
 }
 
-std::size_t MEDFileStructuredMesh::getHeapMemorySize() const
+std::size_t MEDFileStructuredMesh::getHeapMemorySizeWithoutChildren() const
 {
-  std::size_t ret=MEDFileMesh::getHeapMemorySize();
-  if((const DataArrayInt*)_fam_nodes)
-    ret+=_fam_nodes->getHeapMemorySize();
-  if((const DataArrayInt*)_num_nodes)
-    ret+=_num_nodes->getHeapMemorySize();
-  if((const DataArrayInt*)_fam_cells)
-    ret+=_fam_cells->getHeapMemorySize();
-  if((const DataArrayInt*)_num_cells)
-    ret+=_num_cells->getHeapMemorySize();
-  if((const DataArrayInt*)_rev_num_nodes)
-    ret+=_rev_num_nodes->getHeapMemorySize();
-  if((const DataArrayInt*)_rev_num_cells)
-    ret+=_rev_num_cells->getHeapMemorySize();
+  return MEDFileMesh::getHeapMemorySizeWithoutChildren();
+}
+
+std::vector<RefCountObject *> MEDFileStructuredMesh::getDirectChildren() const
+{
+  std::vector<RefCountObject *> ret(MEDFileMesh::getDirectChildren());
+  if((const DataArrayInt *)_fam_nodes)
+    ret.push_back(const_cast<DataArrayInt *>((const DataArrayInt *)_fam_nodes));
+  if((const DataArrayInt *)_num_nodes)
+    ret.push_back(const_cast<DataArrayInt *>((const DataArrayInt *)_num_nodes));
+  if((const DataArrayInt *)_fam_cells)
+    ret.push_back(const_cast<DataArrayInt *>((const DataArrayInt *)_fam_cells));
+  if((const DataArrayInt *)_num_cells)
+    ret.push_back(const_cast<DataArrayInt *>((const DataArrayInt *)_num_nodes));
+  if((const DataArrayInt *)_rev_num_nodes)
+    ret.push_back(const_cast<DataArrayInt *>((const DataArrayInt *)_rev_num_nodes));
+  if((const DataArrayInt *)_rev_num_cells)
+    ret.push_back(const_cast<DataArrayInt *>((const DataArrayInt *)_rev_num_cells));
   return ret;
 }
 
@@ -4594,11 +4610,16 @@ MEDFileCMesh *MEDFileCMesh::New(const char *fileName, const char *mName, int dt,
   return new MEDFileCMesh(fid,mName,dt,it,mrs);
 }
 
-std::size_t MEDFileCMesh::getHeapMemorySize() const
+std::size_t MEDFileCMesh::getHeapMemorySizeWithoutChildren() const
 {
-  std::size_t ret=MEDFileStructuredMesh::getHeapMemorySize();
+  return MEDFileStructuredMesh::getHeapMemorySizeWithoutChildren();
+}
+
+std::vector<RefCountObject *> MEDFileCMesh::getDirectChildren() const
+{
+  std::vector<RefCountObject *> ret(MEDFileStructuredMesh::getDirectChildren());
   if((const MEDCouplingCMesh *)_cmesh)
-    ret+=_cmesh->getHeapMemorySize();
+    ret.push_back(const_cast<MEDCouplingCMesh *>((const MEDCouplingCMesh *)_cmesh));
   return ret;
 }
 
@@ -4834,11 +4855,16 @@ MEDFileCurveLinearMesh *MEDFileCurveLinearMesh::New(const char *fileName, const
   return new MEDFileCurveLinearMesh(fid,mName,dt,it,mrs);
 }
 
-std::size_t MEDFileCurveLinearMesh::getHeapMemorySize() const
+std::size_t MEDFileCurveLinearMesh::getHeapMemorySizeWithoutChildren() const
+{
+  return MEDFileStructuredMesh::getHeapMemorySizeWithoutChildren();
+}
+
+std::vector<RefCountObject *> MEDFileCurveLinearMesh::getDirectChildren() const
 {
-  std::size_t ret=MEDFileStructuredMesh::getHeapMemorySize();
+  std::vector<RefCountObject *> ret(MEDFileStructuredMesh::getDirectChildren());
   if((const MEDCouplingCurveLinearMesh *)_clmesh)
-    ret+=_clmesh->getHeapMemorySize();
+    ret.push_back(const_cast<MEDCouplingCurveLinearMesh *>((const MEDCouplingCurveLinearMesh *)_clmesh));
   return ret;
 }
 
@@ -5041,11 +5067,20 @@ MEDFileMeshMultiTS *MEDFileMeshMultiTS::deepCpy() const throw(INTERP_KERNEL::Exc
   return ret.retn();
 }
 
-std::size_t MEDFileMeshMultiTS::getHeapMemorySize() const
+std::size_t MEDFileMeshMultiTS::getHeapMemorySizeWithoutChildren() const
+{
+  return _mesh_one_ts.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileMesh>);
+}
+
+std::vector<RefCountObject *> MEDFileMeshMultiTS::getDirectChildren() const
 {
-  std::size_t ret=_mesh_one_ts.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileMesh>);
+  std::vector<RefCountObject *> ret;
   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> >::const_iterator it=_mesh_one_ts.begin();it!=_mesh_one_ts.end();it++)
-    ret+=(*it)->getHeapMemorySize();
+    {
+      const MEDFileMesh *cur(*it);
+      if(cur)
+        ret.push_back(const_cast<MEDFileMesh *>(cur));
+    }
   return ret;
 }
 
@@ -5317,13 +5352,21 @@ MEDFileMeshes *MEDFileMeshes::deepCpy() const throw(INTERP_KERNEL::Exception)
   return ret.retn();
 }
 
-std::size_t MEDFileMeshes::getHeapMemorySize() const
+std::size_t MEDFileMeshes::getHeapMemorySizeWithoutChildren() const
+{
+  return _meshes.capacity()*(sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileMeshMultiTS>));
+}
+
+std::vector<RefCountObject *> MEDFileMeshes::getDirectChildren() const
 {
-  std::size_t ret=_meshes.capacity()*(sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileMeshMultiTS>));
+  std::vector<RefCountObject *> ret;
   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileMeshMultiTS> >::const_iterator it=_meshes.begin();it!=_meshes.end();it++)
-    if((const MEDFileMeshMultiTS*)*it)
-      ret+=(*it)->getHeapMemorySize();
-  return ret; 
+    {
+      const MEDFileMeshMultiTS *cur(*it);
+      if(cur)
+        ret.push_back(const_cast<MEDFileMeshMultiTS *>(cur));
+    }
+  return ret;
 }
 
 std::string MEDFileMeshes::simpleRepr() const
index ba03076bb97f7236304ae739510433cda1bba671..742ad47c744c062022b655523ac08a10f6b59058 100644 (file)
@@ -39,7 +39,8 @@ namespace ParaMEDMEM
   public:
     static MEDFileMesh *New(const char *fileName, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception);
     static MEDFileMesh *New(const char *fileName, const char *mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception);
-    std::size_t getHeapMemorySize() const;
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<RefCountObject *> getDirectChildren() const;
     virtual MEDFileMesh *createNewEmpty() const throw(INTERP_KERNEL::Exception) = 0;
     virtual MEDFileMesh *deepCpy() const throw(INTERP_KERNEL::Exception) = 0;
     virtual MEDFileMesh *shallowCpy() const throw(INTERP_KERNEL::Exception) = 0;
@@ -191,7 +192,8 @@ namespace ParaMEDMEM
     static MEDFileUMesh *New(const char *fileName, const char *mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception);
     static MEDFileUMesh *New(const char *fileName, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception);
     static MEDFileUMesh *New();
-    std::size_t getHeapMemorySize() const;
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<RefCountObject *> getDirectChildren() const;
     MEDFileMesh *createNewEmpty() const throw(INTERP_KERNEL::Exception);
     MEDFileMesh *deepCpy() const throw(INTERP_KERNEL::Exception);
     MEDFileMesh *shallowCpy() const throw(INTERP_KERNEL::Exception);
@@ -288,7 +290,8 @@ namespace ParaMEDMEM
   {
     friend class MEDFileMesh;
   public:
-    std::size_t getHeapMemorySize() const;
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<RefCountObject *> getDirectChildren() const;
     int getMaxAbsFamilyIdInArrays() const throw(INTERP_KERNEL::Exception);
     int getMaxFamilyIdInArrays() const throw(INTERP_KERNEL::Exception);
     int getMinFamilyIdInArrays() const throw(INTERP_KERNEL::Exception);
@@ -338,7 +341,8 @@ namespace ParaMEDMEM
     static MEDFileCMesh *New();
     static MEDFileCMesh *New(const char *fileName, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception);
     static MEDFileCMesh *New(const char *fileName, const char *mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception);
-    std::size_t getHeapMemorySize() const;
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<RefCountObject *> getDirectChildren() const;
     MEDFileMesh *createNewEmpty() const throw(INTERP_KERNEL::Exception);
     MEDFileMesh *deepCpy() const throw(INTERP_KERNEL::Exception);
     MEDFileMesh *shallowCpy() const throw(INTERP_KERNEL::Exception);
@@ -367,7 +371,8 @@ namespace ParaMEDMEM
     static MEDFileCurveLinearMesh *New();
     static MEDFileCurveLinearMesh *New(const char *fileName, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception);
     static MEDFileCurveLinearMesh *New(const char *fileName, const char *mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception);
-    std::size_t getHeapMemorySize() const;
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<RefCountObject *> getDirectChildren() const;
     MEDFileMesh *createNewEmpty() const throw(INTERP_KERNEL::Exception);
     MEDFileMesh *deepCpy() const throw(INTERP_KERNEL::Exception);
     MEDFileMesh *shallowCpy() const throw(INTERP_KERNEL::Exception);
@@ -396,7 +401,8 @@ namespace ParaMEDMEM
     static MEDFileMeshMultiTS *New(const char *fileName) throw(INTERP_KERNEL::Exception);
     static MEDFileMeshMultiTS *New(const char *fileName, const char *mName) throw(INTERP_KERNEL::Exception);
     MEDFileMeshMultiTS *deepCpy() const throw(INTERP_KERNEL::Exception);
-    std::size_t getHeapMemorySize() const;
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<RefCountObject *> getDirectChildren() const;
     std::string getName() const throw(INTERP_KERNEL::Exception);
     void setName(const char *newMeshName) throw(INTERP_KERNEL::Exception);
     bool changeNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception);
@@ -421,7 +427,8 @@ namespace ParaMEDMEM
     static MEDFileMeshes *New();
     static MEDFileMeshes *New(const char *fileName) throw(INTERP_KERNEL::Exception);
     MEDFileMeshes *deepCpy() const throw(INTERP_KERNEL::Exception);
-    std::size_t getHeapMemorySize() const;
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<RefCountObject *> getDirectChildren() const;
     std::string simpleRepr() const;
     void simpleReprWithoutHeader(std::ostream& oss) const;
     void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
index 0725d6890394d0c7a560de9602549be4700e7e8a..5bad3f8d9e12d15d2ca97455fa7262388c5bcd67 100644 (file)
@@ -40,6 +40,25 @@ MEDFileUMeshPerType *MEDFileUMeshPerType::New(med_idt fid, const char *mName, in
   return new MEDFileUMeshPerType(fid,mName,dt,it,mdim,geoElt,geoElt2,whichEntity,mrs);
 }
 
+std::size_t MEDFileUMeshPerType::getHeapMemorySizeWithoutChildren() const
+{
+  return 0;
+}
+
+std::vector<RefCountObject *> MEDFileUMeshPerType::getDirectChildren() const
+{
+  std::vector<RefCountObject *> ret;
+  if((const MEDCoupling1GTUMesh *)_m)
+    ret.push_back(const_cast<MEDCoupling1GTUMesh *>((const MEDCoupling1GTUMesh *)_m));
+  if((const DataArrayInt *)_num)
+    ret.push_back(const_cast<DataArrayInt *>((const DataArrayInt *)_num));
+  if((const DataArrayInt *)_fam)
+    ret.push_back(const_cast<DataArrayInt *>((const DataArrayInt *)_fam));
+  if((const DataArrayAsciiChar *)_names)
+    ret.push_back(const_cast<DataArrayAsciiChar *>((const DataArrayAsciiChar *)_names));
+  return ret;
+}
+
 bool MEDFileUMeshPerType::isExisting(med_idt fid, const char *mName, int dt, int it, med_geometry_type geoElt, med_entity_type& whichEntity)
 {
   static const med_entity_type entities[3]={MED_CELL,MED_DESCENDING_FACE,MED_DESCENDING_EDGE};
index af728268a493daf334b08082bdffba306d5f1d79..ee3ccda985683c144ed25aa88023b5533c4662b5 100644 (file)
@@ -39,7 +39,8 @@ namespace ParaMEDMEM
   public:
     static MEDFileUMeshPerType *New(med_idt fid, const char *mName, int dt, int it, int mdim, med_geometry_type geoElt, INTERP_KERNEL::NormalizedCellType geoElt2, MEDFileMeshReadSelector *mrs);
     static bool isExisting(med_idt fid, const char *mName, int dt, int it, med_geometry_type geoElt, med_entity_type& whichEntity);
-    std::size_t getHeapMemorySize() const { return 0; }
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<RefCountObject *> getDirectChildren() const;
     int getDim() const;
     MEDCoupling1GTUMesh *getMesh() const { return const_cast<MEDCoupling1GTUMesh *>((const MEDCoupling1GTUMesh *)_m); }
     const DataArrayInt *getFam() const { return _fam; }
index a4722e9b46e62e9218da8be3db0d8f820a1eb019..ad8c2dae0acd2c359fb31f2975e45188334a2a5a 100644 (file)
@@ -40,6 +40,16 @@ MEDFileMeshL2::MEDFileMeshL2():_name(MED_NAME_SIZE),_description(MED_COMMENT_SIZ
 {
 }
 
+std::size_t MEDFileMeshL2::getHeapMemorySizeWithoutChildren() const
+{
+  return 0;
+}
+
+std::vector<RefCountObject *> MEDFileMeshL2::getDirectChildren() const
+{
+  return std::vector<RefCountObject *>();
+}
+
 int MEDFileMeshL2::GetMeshIdFromName(med_idt fid, const char *mname, ParaMEDMEM::MEDCouplingMeshType& meshType, int& dt, int& it, std::string& dtunit1) throw(INTERP_KERNEL::Exception)
 {
   med_mesh_type type_maillage;
@@ -552,18 +562,23 @@ MEDFileUMeshSplitL1::MEDFileUMeshSplitL1(MEDCouplingUMesh *m, bool newOrOld):_m(
   assignMesh(m,newOrOld);
 }
 
-std::size_t MEDFileUMeshSplitL1::getHeapMemorySize() const
+std::size_t MEDFileUMeshSplitL1::getHeapMemorySizeWithoutChildren() const
 {
-  std::size_t ret=0;
-  ret+=_m_by_types.getHeapMemorySize();
+  return 0;
+}
+
+std::vector<RefCountObject *> MEDFileUMeshSplitL1::getDirectChildren() const
+{
+  std::vector<RefCountObject *> ret;
+  ret.push_back(const_cast<MEDFileUMeshAggregateCompute *>(&_m_by_types));
   if((const DataArrayInt*)_fam)
-    ret+=_fam->getHeapMemorySize();
+    ret.push_back(const_cast<DataArrayInt*>((const DataArrayInt*)_fam));
   if((const DataArrayInt*)_num)
-    ret+=_num->getHeapMemorySize();
+    ret.push_back(const_cast<DataArrayInt*>((const DataArrayInt*)_num));
   if((const DataArrayInt*)_rev_num)
-    ret+=_rev_num->getHeapMemorySize();
+    ret.push_back(const_cast<DataArrayInt*>((const DataArrayInt*)_rev_num));
   if((const DataArrayAsciiChar*)_names)
-    ret+=_names->getHeapMemorySize();
+    ret.push_back(const_cast<DataArrayAsciiChar*>((const DataArrayAsciiChar*)_names));
   return ret;
 }
 
@@ -1057,33 +1072,24 @@ std::size_t MEDFileUMeshAggregateCompute::getTimeOfUMesh() const
   return m->getTimeOfThis();
 }
 
-/*!
- * Coordinates pointer is not counted because father instance already count it !
- */
-std::size_t MEDFileUMeshAggregateCompute::getHeapMemorySize() const
-{ 
-  std::size_t ret(0);
-  ret+=_m_parts.size()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh>);
-  std::size_t sz(_m_parts.size());
-  for(std::size_t i=0;i<sz;i++)
+std::size_t MEDFileUMeshAggregateCompute::getHeapMemorySizeWithoutChildren() const
+{
+  std::size_t ret(_m_parts.size()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh>));
+  return ret;
+}
+
+std::vector<RefCountObject *> MEDFileUMeshAggregateCompute::getDirectChildren() const
+{
+  std::vector<RefCountObject *> ret;
+  for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++)
     {
-      const MEDCoupling1GTUMesh *pt(_m_parts[i]);
-      if(pt)
-        {
-          ret+=pt->getHeapMemorySize();
-          const DataArrayDouble *coo(pt->getCoords());
-          if(coo)
-            ret-=coo->getHeapMemorySize();
-        }
+      const MEDCoupling1GTUMesh *cur(*it);
+      if(cur)
+        ret.push_back(const_cast<MEDCoupling1GTUMesh *>(cur));
     }
   const MEDCouplingUMesh *m(_m);
   if(m)
-    {
-      ret+=m->getHeapMemorySize();
-      const DataArrayDouble *coo(m->getCoords());
-      if(coo)
-            ret-=coo->getHeapMemorySize();
-    }
+    ret.push_back(const_cast<MEDCouplingUMesh *>(m));
   return ret;
 }
 
index 56e19db6fbbfad5defa8e6d7138a798f626864b5..a44312b408cd0b0315259cb71eddeea7f491125c 100644 (file)
@@ -42,7 +42,8 @@ namespace ParaMEDMEM
   {
   public:
     MEDFileMeshL2();
-    std::size_t getHeapMemorySize() const { return 0; }
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<RefCountObject *> getDirectChildren() const;
     const char *getName() const { return _name.getReprForWrite(); }
     const char *getDescription() const { return _description.getReprForWrite(); }
     const char *getUnivName() const { return _univ_name.getReprForWrite(); }
@@ -136,7 +137,7 @@ namespace ParaMEDMEM
     mutable MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> _m;
   };
 
-  class MEDFileUMeshAggregateCompute
+  class MEDFileUMeshAggregateCompute : public RefCountObject
   {
   public:
     MEDFileUMeshAggregateCompute();
@@ -147,7 +148,8 @@ namespace ParaMEDMEM
     std::vector<MEDCoupling1GTUMesh *> getPartsWithoutComputation() const throw(INTERP_KERNEL::Exception);
     MEDCoupling1GTUMesh *getPartWithoutComputation(INTERP_KERNEL::NormalizedCellType gt) const throw(INTERP_KERNEL::Exception);
     std::size_t getTimeOfThis() const;
-    std::size_t getHeapMemorySize() const;
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<RefCountObject *> getDirectChildren() const;
     MEDFileUMeshAggregateCompute deepCpy(DataArrayDouble *coords) const;
     bool isEqual(const MEDFileUMeshAggregateCompute& other, double eps, std::string& what) const;
     void clearNonDiscrAttributes() const;
@@ -176,7 +178,8 @@ namespace ParaMEDMEM
     MEDFileUMeshSplitL1(const MEDFileUMeshL2& l2, const char *mName, int id);
     MEDFileUMeshSplitL1(MEDCouplingUMesh *m);
     MEDFileUMeshSplitL1(MEDCouplingUMesh *m, bool newOrOld);
-    std::size_t getHeapMemorySize() const;
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<RefCountObject *> getDirectChildren() const;
     MEDFileUMeshSplitL1 *deepCpy(DataArrayDouble *coords) const;
     void setCoords(DataArrayDouble *coords) throw(INTERP_KERNEL::Exception);
     bool isEqual(const MEDFileUMeshSplitL1 *other, double eps, std::string& what) const;
index 09536b60c73550070791607521c297da40b07f37..ad675d51fff4622b1429fc06caad847b5b8d0dce 100644 (file)
@@ -67,11 +67,16 @@ bool MEDFileParameterDouble1TSWTI::isEqual(const MEDFileParameter1TS *other, dou
   return true;
 }
 
-std::size_t MEDFileParameterDouble1TSWTI::getHeapMemorySize() const
+std::size_t MEDFileParameterDouble1TSWTI::getHeapMemorySizeWithoutChildren() const
 {
   return sizeof(MEDFileParameterDouble1TSWTI);
 }
 
+std::vector<RefCountObject *> MEDFileParameterDouble1TSWTI::getDirectChildren() const
+{
+  return std::vector<RefCountObject *>();
+}
+
 std::string MEDFileParameterDouble1TSWTI::simpleRepr() const
 {
   std::ostringstream oss;
@@ -340,11 +345,16 @@ std::string MEDFileParameterDouble1TS::simpleRepr() const
   return oss.str();
 }
 
-std::size_t MEDFileParameterDouble1TS::getHeapMemorySize() const
+std::size_t MEDFileParameterDouble1TS::getHeapMemorySizeWithoutChildren() const
 {
   return getHeapMemSizeOfStrings()+sizeof(MEDFileParameterDouble1TS);
 }
 
+std::vector<RefCountObject *> MEDFileParameterDouble1TS::getDirectChildren() const
+{
+  return std::vector<RefCountObject *>();
+}
+
 void MEDFileParameterDouble1TS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
 {
   med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
@@ -469,17 +479,23 @@ void MEDFileParameterMultiTS::finishLoading(med_idt fid, med_parameter_type typ,
     }
 }
 
-std::size_t MEDFileParameterMultiTS::getHeapMemorySize() const
+std::size_t MEDFileParameterMultiTS::getHeapMemorySizeWithoutChildren() const
 {
-  std::size_t ret=sizeof(MEDFileParameterMultiTS);
-  std::size_t ret2=sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileParameter1TS>)*_param_per_ts.capacity();
-  for(std::size_t i=0;i<_param_per_ts.size();i++)
+  std::size_t ret(sizeof(MEDFileParameterMultiTS));
+  ret+=sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileParameter1TS>)*_param_per_ts.capacity();
+  return ret;
+}
+
+std::vector<RefCountObject *> MEDFileParameterMultiTS::getDirectChildren() const
+{
+  std::vector<RefCountObject *> ret;
+  for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileParameter1TS> >::const_iterator it=_param_per_ts.begin();it!=_param_per_ts.end();it++)
     {
-      const MEDFileParameter1TS *pt(_param_per_ts[i]);
-      if(pt)
-        ret2+=pt->getHeapMemorySize();
+      const MEDFileParameter1TS *elt(*it);
+      if(elt)
+        ret.push_back(const_cast<MEDFileParameter1TS *>(elt));
     }
-  return ret2+ret;
+  return ret;
 }
 
 MEDFileParameterMultiTS *MEDFileParameterMultiTS::deepCpy() const throw(INTERP_KERNEL::Exception)
@@ -714,17 +730,23 @@ MEDFileParameters::MEDFileParameters()
 {
 }
 
-std::size_t MEDFileParameters::getHeapMemorySize() const
+std::size_t MEDFileParameters::getHeapMemorySizeWithoutChildren() const
 {
-  std::size_t ret=sizeof(MEDFileParameters);
-  std::size_t ret2=sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileParameterMultiTS>)*_params.capacity();
-  for(std::size_t i=0;i<_params.size();i++)
+  std::size_t ret(sizeof(MEDFileParameters));
+  ret+=sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileParameterMultiTS>)*_params.capacity();
+  return ret;
+}
+
+std::vector<RefCountObject *> MEDFileParameters::getDirectChildren() const
+{
+  std::vector<RefCountObject *> ret;
+  for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileParameterMultiTS> >::const_iterator it=_params.begin();it!=_params.end();it++)
     {
-      const MEDFileParameterMultiTS *pt(_params[i]);
-      if(pt)
-        ret2+=pt->getHeapMemorySize();
+      const MEDFileParameterMultiTS *elt(*it);
+      if(elt)
+        ret.push_back(const_cast<MEDFileParameterMultiTS *>(elt));
     }
-  return ret2+ret;
+  return ret;
 }
 
 MEDFileParameters *MEDFileParameters::deepCpy() const throw(INTERP_KERNEL::Exception)
index cb4c6fad1e8347be21cdcc5aefa7277e5ff15894..21240cb0b228a83bcb7b140b0e9035285ff040de 100644 (file)
@@ -62,7 +62,8 @@ namespace ParaMEDMEM
     void setValue(double val) throw(INTERP_KERNEL::Exception) { _arr=val; }
     double getValue() const throw(INTERP_KERNEL::Exception) { return _arr; }
     bool isEqual(const MEDFileParameter1TS *other, double eps, std::string& what) const;
-    std::size_t getHeapMemorySize() const;
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<RefCountObject *> getDirectChildren() const;
     void readValue(med_idt fid, const std::string& name) throw(INTERP_KERNEL::Exception);
     std::string simpleRepr() const;
   protected:
@@ -104,7 +105,8 @@ namespace ParaMEDMEM
     virtual MEDFileParameter1TS *deepCpy() const throw(INTERP_KERNEL::Exception);
     virtual bool isEqual(const MEDFileParameter1TS *other, double eps, std::string& what) const;
     virtual std::string simpleRepr() const;
-    std::size_t getHeapMemorySize() const;
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<RefCountObject *> getDirectChildren() const;
     void setName(const char *name) throw(INTERP_KERNEL::Exception) { _name=name; }
     std::string getName() const throw(INTERP_KERNEL::Exception) { return _name; }
     void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
@@ -123,7 +125,8 @@ namespace ParaMEDMEM
     static MEDFileParameterMultiTS *New(const char *fileName, const char *paramName) throw(INTERP_KERNEL::Exception);
     std::string getName() const { return _name; }
     void setName(const char *name) { _name=name; }
-    std::size_t getHeapMemorySize() const;
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<RefCountObject *> getDirectChildren() const;
     MEDFileParameterMultiTS *deepCpy() const throw(INTERP_KERNEL::Exception);
     bool isEqual(const MEDFileParameterMultiTS *other, double eps, std::string& what) const;
     void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
@@ -153,7 +156,8 @@ namespace ParaMEDMEM
   public:
     static MEDFileParameters *New();
     static MEDFileParameters *New(const char *fileName) throw(INTERP_KERNEL::Exception);
-    std::size_t getHeapMemorySize() const;
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<RefCountObject *> getDirectChildren() const;
     MEDFileParameters *deepCpy() const throw(INTERP_KERNEL::Exception);
     bool isEqual(const MEDFileParameters *other, double eps, std::string& what) const;
     void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
index fcbbd5ef26038c499f95ae81120254c02ae876be..65093499cbb3d0acf9e63ad343c034e42ffe7b58 100644 (file)
@@ -81,6 +81,16 @@ SauvReader::~SauvReader()
   _fileReader->decrRef();
 }
 
+std::size_t SauvReader::getHeapMemorySizeWithoutChildren() const
+{
+  return 0;
+}
+
+std::vector<RefCountObject *> SauvReader::getDirectChildren() const
+{
+  return std::vector<RefCountObject *>();
+}
+
 //================================================================================
 /*!
  * \brief Return current line of ASCII file to report an error
index d2d52cc624dd6c672fa807b5caa6b0ed10c7028f..01b87d08ef90b80d58b8a50adb46a9fdd197ab0a 100644 (file)
@@ -51,8 +51,8 @@ class MEDLOADER_EXPORT SauvReader : public ParaMEDMEM::RefCountObject
   ~SauvReader();
 
  private:
-  std::size_t getHeapMemorySize() const { return 0; }
-
+  std::size_t getHeapMemorySizeWithoutChildren() const;
+  std::vector<RefCountObject *> getDirectChildren() const;
   void readRecord2();
   void readRecord4();
   void readRecord7();
index f16ba02c1bcf6509098e51a7862e9128e6c0579c..25bec6d3b07aea407944ccc0a5c1e52961a2b068 100644 (file)
@@ -110,7 +110,8 @@ namespace SauvUtilities
     virtual double getDouble() const = 0;
     virtual std::string getName() const = 0;
   protected:
-    std::size_t getHeapMemorySize() const { return 0; }
+    std::size_t getHeapMemorySizeWithoutChildren() const { return 0; }
+    std::vector<RefCountObject *> getDirectChildren() const { return std::vector<RefCountObject *>(); }
   protected:
     std::string _fileName, _curLocale;
     int _iRead, _nbToRead;
index 4a2105620d7307a4a8198c15a0a68402745806c2..908f7a5043ddd75c7992345485c5a318e6927484 100644 (file)
@@ -223,6 +223,16 @@ SauvWriter* SauvWriter::New()
   return new SauvWriter;
 }
 
+std::size_t SauvWriter::getHeapMemorySizeWithoutChildren() const
+{
+  return 0;
+}
+
+std::vector<RefCountObject *> SauvWriter::getDirectChildren() const
+{
+  return std::vector<RefCountObject *>();
+}
+
 //================================================================================
 /*!
  * \brief Fills own DS by MEDFileData
index 3f935aab871975b53f7221d3c54842422fc6cdbb..7f3b13fdeefe27f7dcf4d7055e31ea34ab6fa318 100644 (file)
@@ -51,7 +51,8 @@ namespace ParaMEDMEM
     void write(const char* fileName);
 
   private:
-    std::size_t getHeapMemorySize() const { return 0; }
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<RefCountObject *> getDirectChildren() const;
     /*!
      * \brief Class representing a GIBI sub-mesh (described in the pile 1 of the SAUVE file).
      * It stands for a named med sub-mesh (family, etc) and contains either cell IDs or other sub-meshes.