From: ageay Date: Wed, 21 Aug 2013 11:06:27 +0000 (+0000) Subject: Modification of the getHeapMemorySize computation. X-Git-Tag: V7_3_1b1~188 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=cdc5bc34c06fca639aef39cf04645acf6620ae2a;p=tools%2Fmedcoupling.git Modification of the getHeapMemorySize computation. --- diff --git a/src/MEDCoupling/MEDCoupling1GTUMesh.cxx b/src/MEDCoupling/MEDCoupling1GTUMesh.cxx index 7bb67e8f9..880552182 100644 --- a/src/MEDCoupling/MEDCoupling1GTUMesh.cxx +++ b/src/MEDCoupling/MEDCoupling1GTUMesh.cxx @@ -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 MEDCoupling1SGTUMesh::getDirectChildren() const +{ + std::vector ret(MEDCoupling1GTUMesh::getDirectChildren()); const DataArrayInt *c(_conn); if(c) - ret+=c->getHeapMemorySize(); - return MEDCoupling1GTUMesh::getHeapMemorySize()+ret; + ret.push_back(const_cast(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 MEDCoupling1DGTUMesh::getDirectChildren() const +{ + std::vector ret(MEDCoupling1GTUMesh::getDirectChildren()); const DataArrayInt *c(_conn); if(c) - ret+=c->getHeapMemorySize(); + ret.push_back(const_cast(c)); c=_conn_indx; if(c) - ret+=c->getHeapMemorySize(); - return MEDCoupling1GTUMesh::getHeapMemorySize()+ret; + ret.push_back(const_cast(c)); + return ret; } MEDCouplingMesh *MEDCoupling1DGTUMesh::deepCpy() const diff --git a/src/MEDCoupling/MEDCoupling1GTUMesh.hxx b/src/MEDCoupling/MEDCoupling1GTUMesh.hxx index 8b0cd8752..bb51d043e 100644 --- a/src/MEDCoupling/MEDCoupling1GTUMesh.hxx +++ b/src/MEDCoupling/MEDCoupling1GTUMesh.hxx @@ -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 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 getDirectChildren() const; // overload of MEDCouplingMesh MEDCOUPLING_EXPORT MEDCouplingMeshType getType() const { return SINGLE_DYNAMIC_GEO_TYPE_UNSTRUCTURED; } MEDCOUPLING_EXPORT MEDCouplingMesh *deepCpy() const; diff --git a/src/MEDCoupling/MEDCouplingCMesh.cxx b/src/MEDCoupling/MEDCouplingCMesh.cxx index d6b5e13b7..70d3c7a6a 100644 --- a/src/MEDCoupling/MEDCouplingCMesh.cxx +++ b/src/MEDCoupling/MEDCouplingCMesh.cxx @@ -106,16 +106,21 @@ void MEDCouplingCMesh::updateTime() const updateTimeWith(*_z_array); } -std::size_t MEDCouplingCMesh::getHeapMemorySize() const -{ - std::size_t ret=0; - std::set s; - s.insert(_x_array); s.insert(_y_array); s.insert(_z_array); - s.erase(NULL); - for(std::set::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 MEDCouplingCMesh::getDirectChildren() const +{ + std::vector ret; + if(_x_array) + ret.push_back(const_cast(_x_array)); + if(_y_array) + ret.push_back(const_cast(_y_array)); + if(_z_array) + ret.push_back(const_cast(_z_array)); + return ret; } /*! diff --git a/src/MEDCoupling/MEDCouplingCMesh.hxx b/src/MEDCoupling/MEDCouplingCMesh.hxx index f3e02ee4b..6d1cba871 100644 --- a/src/MEDCoupling/MEDCouplingCMesh.hxx +++ b/src/MEDCoupling/MEDCouplingCMesh.hxx @@ -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 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); diff --git a/src/MEDCoupling/MEDCouplingCurveLinearMesh.cxx b/src/MEDCoupling/MEDCouplingCurveLinearMesh.cxx index 7bfadc53f..31ecee094 100644 --- a/src/MEDCoupling/MEDCouplingCurveLinearMesh.cxx +++ b/src/MEDCoupling/MEDCouplingCurveLinearMesh.cxx @@ -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 MEDCouplingCurveLinearMesh::getDirectChildren() const +{ + std::vector ret; if((const DataArrayDouble *)_coords) - ret+=_coords->getHeapMemorySize(); - return MEDCouplingStructuredMesh::getHeapMemorySize()+ret; + ret.push_back(const_cast((const DataArrayDouble *)_coords)); + return ret; } /*! diff --git a/src/MEDCoupling/MEDCouplingCurveLinearMesh.hxx b/src/MEDCoupling/MEDCouplingCurveLinearMesh.hxx index 66b274344..13df6d043 100644 --- a/src/MEDCoupling/MEDCouplingCurveLinearMesh.hxx +++ b/src/MEDCoupling/MEDCouplingCurveLinearMesh.hxx @@ -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 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); diff --git a/src/MEDCoupling/MEDCouplingDefinitionTime.cxx b/src/MEDCoupling/MEDCouplingDefinitionTime.cxx index 45aa50c7a..19e452461 100644 --- a/src/MEDCoupling/MEDCouplingDefinitionTime.cxx +++ b/src/MEDCoupling/MEDCouplingDefinitionTime.cxx @@ -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 MEDCouplingDefinitionTimeSlice::getDirectChildren() const +{ + return std::vector(); +} + bool MEDCouplingDefinitionTimeSlice::isFullyIncludedInMe(const MEDCouplingDefinitionTimeSlice *other, double eps) const { double t1=getStartTime(); @@ -464,11 +469,16 @@ MEDCouplingDefinitionTime::MEDCouplingDefinitionTime(const std::vector MEDCouplingDefinitionTime::getDirectChildren() const +{ + return std::vector(); +} + void MEDCouplingDefinitionTime::assign(const MEDCouplingDefinitionTime& other) { std::size_t sz=other._slices.size(); diff --git a/src/MEDCoupling/MEDCouplingDefinitionTime.hxx b/src/MEDCoupling/MEDCouplingDefinitionTime.hxx index f6380d0e6..deb519243 100644 --- a/src/MEDCoupling/MEDCouplingDefinitionTime.hxx +++ b/src/MEDCoupling/MEDCouplingDefinitionTime.hxx @@ -51,7 +51,8 @@ namespace ParaMEDMEM virtual double getEndTime() const = 0; virtual void getTinySerializationInformation(std::vector& tiI, std::vector& tiD) const = 0; virtual TypeOfTimeDiscretization getTimeType() const = 0; - std::size_t getHeapMemorySize() const; + std::size_t getHeapMemorySizeWithoutChildren() const; + std::vector 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& fs, const std::vector& meshRefs, const std::vector >& arrRefs) throw(INTERP_KERNEL::Exception); - std::size_t getHeapMemorySize() const; + std::size_t getHeapMemorySizeWithoutChildren() const; + std::vector getDirectChildren() const; void assign(const MEDCouplingDefinitionTime& other); bool isEqual(const MEDCouplingDefinitionTime& other) const; double getTimeResolution() const { return _eps; } diff --git a/src/MEDCoupling/MEDCouplingExtrudedMesh.cxx b/src/MEDCoupling/MEDCouplingExtrudedMesh.cxx index fd3604037..14a29179d 100644 --- a/src/MEDCoupling/MEDCouplingExtrudedMesh.cxx +++ b/src/MEDCoupling/MEDCouplingExtrudedMesh.cxx @@ -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 MEDCouplingExtrudedMesh::getDirectChildren() const +{ + std::vector ret; if(_mesh2D) - ret+=_mesh2D->getHeapMemorySize(); + ret.push_back(const_cast(_mesh2D)); if(_mesh1D) - ret+=_mesh1D->getHeapMemorySize(); + ret.push_back(const_cast(_mesh1D)); if(_mesh3D_ids) - ret+=_mesh3D_ids->getHeapMemorySize(); - return MEDCouplingMesh::getHeapMemorySize()+ret; + ret.push_back(const_cast(_mesh3D_ids)); + return ret; } /*! diff --git a/src/MEDCoupling/MEDCouplingExtrudedMesh.hxx b/src/MEDCoupling/MEDCouplingExtrudedMesh.hxx index 1c97019ad..8aa72199d 100644 --- a/src/MEDCoupling/MEDCouplingExtrudedMesh.hxx +++ b/src/MEDCoupling/MEDCouplingExtrudedMesh.hxx @@ -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 getDirectChildren() const; void copyTinyStringsFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception); int getNumberOfCells() const; int getNumberOfNodes() const; diff --git a/src/MEDCoupling/MEDCouplingField.cxx b/src/MEDCoupling/MEDCouplingField.cxx index b00d779ee..c7813180a 100644 --- a/src/MEDCoupling/MEDCouplingField.cxx +++ b/src/MEDCoupling/MEDCouplingField.cxx @@ -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 MEDCouplingField::getDirectChildren() const +{ + std::vector ret; if(_mesh) - ret+=_mesh->getHeapMemorySize(); + ret.push_back(const_cast(_mesh)); if((const MEDCouplingFieldDiscretization *)_type) - ret+=_type->getHeapMemorySize(); + ret.push_back(const_cast((const MEDCouplingFieldDiscretization *)_type)); return ret; } diff --git a/src/MEDCoupling/MEDCouplingField.hxx b/src/MEDCoupling/MEDCouplingField.hxx index 284d04799..5cf5bbf08 100644 --- a/src/MEDCoupling/MEDCouplingField.hxx +++ b/src/MEDCoupling/MEDCouplingField.hxx @@ -84,7 +84,8 @@ namespace ParaMEDMEM void getCellIdsHavingGaussLocalization(int locId, std::vector& 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 getDirectChildren() const; // for MED file RW int getNumberOfTuplesExpectedRegardingCode(const std::vector& code, const std::vector& idsPerType) const throw(INTERP_KERNEL::Exception); virtual void reprQuickOverview(std::ostream& stream) const throw(INTERP_KERNEL::Exception) = 0; diff --git a/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx b/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx index 4742a3ed0..04dc70908 100644 --- a/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx +++ b/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx @@ -179,11 +179,16 @@ void MEDCouplingFieldDiscretization::updateTime() const { } -std::size_t MEDCouplingFieldDiscretization::getHeapMemorySize() const +std::size_t MEDCouplingFieldDiscretization::getHeapMemorySizeWithoutChildren() const { return 0; } +std::vector MEDCouplingFieldDiscretization::getDirectChildren() const +{ + return std::vector(); +} + /*! * 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 MEDCouplingFieldDiscretizationPerCell::getDirectChildren() const { - std::size_t ret=0; + std::vector ret(MEDCouplingFieldDiscretization::getDirectChildren()); if(_discr_per_cell) - ret+=_discr_per_cell->getHeapMemorySize(); + ret.push_back(const_cast(_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::const_iterator it=_loc.begin();it!=_loc.end();it++) ret+=(*it).getHeapMemorySize(); - return MEDCouplingFieldDiscretizationPerCell::getHeapMemorySize()+ret; + return ret; } const char *MEDCouplingFieldDiscretizationGauss::getRepr() const diff --git a/src/MEDCoupling/MEDCouplingFieldDiscretization.hxx b/src/MEDCoupling/MEDCouplingFieldDiscretization.hxx index 2cbd5511f..a56d3b25c 100644 --- a/src/MEDCoupling/MEDCouplingFieldDiscretization.hxx +++ b/src/MEDCoupling/MEDCouplingFieldDiscretization.hxx @@ -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 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 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& code, const std::vector& idsPerType) const throw(INTERP_KERNEL::Exception); int getNumberOfTuples(const MEDCouplingMesh *mesh) const throw(INTERP_KERNEL::Exception); int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const; diff --git a/src/MEDCoupling/MEDCouplingFieldDouble.cxx b/src/MEDCoupling/MEDCouplingFieldDouble.cxx index b7b3711b5..954408c64 100644 --- a/src/MEDCoupling/MEDCouplingFieldDouble.cxx +++ b/src/MEDCoupling/MEDCouplingFieldDouble.cxx @@ -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 MEDCouplingFieldDouble::getDirectChildren() const +{ + std::vector ret(MEDCouplingField::getDirectChildren()); if(_time_discr) - ret+=_time_discr->getHeapMemorySize(); - return MEDCouplingField::getHeapMemorySize()+ret; + { + std::vector ret2(_time_discr->getDirectChildren()); + ret.insert(ret.end(),ret2.begin(),ret2.end()); + } + return ret; } /*! diff --git a/src/MEDCoupling/MEDCouplingFieldDouble.hxx b/src/MEDCoupling/MEDCouplingFieldDouble.hxx index 3a3533e87..a99041fed 100644 --- a/src/MEDCoupling/MEDCouplingFieldDouble.hxx +++ b/src/MEDCoupling/MEDCouplingFieldDouble.hxx @@ -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 getDirectChildren() const; // void getTinySerializationIntInformation(std::vector& tinyInfo) const; void getTinySerializationDbleInformation(std::vector& tinyInfo) const; diff --git a/src/MEDCoupling/MEDCouplingMemArray.cxx b/src/MEDCoupling/MEDCouplingMemArray.cxx index 424a20986..3dc5f450d 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.cxx +++ b/src/MEDCoupling/MEDCouplingMemArray.cxx @@ -110,7 +110,7 @@ void DataArrayDouble::FindClosestTupleIdAlg(const BBTreePts& 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 DataArray::getDirectChildren() const +{ + return std::vector(); +} + /*! * 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) { diff --git a/src/MEDCoupling/MEDCouplingMemArray.hxx b/src/MEDCoupling/MEDCouplingMemArray.hxx index 8d52c7033..6000da785 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.hxx +++ b/src/MEDCoupling/MEDCouplingMemArray.hxx @@ -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 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& 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); diff --git a/src/MEDCoupling/MEDCouplingMemArrayChar.cxx b/src/MEDCoupling/MEDCouplingMemArrayChar.cxx index d363454bb..c9cb325c0 100644 --- a/src/MEDCoupling/MEDCouplingMemArrayChar.cxx +++ b/src/MEDCoupling/MEDCouplingMemArrayChar.cxx @@ -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; } /*! diff --git a/src/MEDCoupling/MEDCouplingMesh.cxx b/src/MEDCoupling/MEDCouplingMesh.cxx index 1615842b6..a9b28d585 100644 --- a/src/MEDCoupling/MEDCouplingMesh.cxx +++ b/src/MEDCoupling/MEDCouplingMesh.cxx @@ -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(); } diff --git a/src/MEDCoupling/MEDCouplingMesh.hxx b/src/MEDCoupling/MEDCouplingMesh.hxx index af3d71d02..f12406fab 100644 --- a/src/MEDCoupling/MEDCouplingMesh.hxx +++ b/src/MEDCoupling/MEDCouplingMesh.hxx @@ -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; } diff --git a/src/MEDCoupling/MEDCouplingMultiFields.cxx b/src/MEDCoupling/MEDCouplingMultiFields.cxx index 4e3c6580e..436ab8d20 100644 --- a/src/MEDCoupling/MEDCouplingMultiFields.cxx +++ b/src/MEDCoupling/MEDCouplingMultiFields.cxx @@ -190,19 +190,20 @@ void MEDCouplingMultiFields::updateTime() const updateTimeWith(*(*it)); } -std::size_t MEDCouplingMultiFields::getHeapMemorySize() const +std::size_t MEDCouplingMultiFields::getHeapMemorySizeWithoutChildren() const { - std::vector tmp; - std::vector< std::vector > tmp2; - std::vector ms=getDifferentMeshes(tmp); - std::vector arrs=getDifferentArrays(tmp2); - std::size_t ret=0; - for(std::vector::const_iterator it=ms.begin();it!=ms.end();it++) - if(*it) - ret+=(*it)->getHeapMemorySize(); - for(std::vector::const_iterator it=arrs.begin();it!=arrs.end();it++) - if(*it) - ret+=(*it)->getHeapMemorySize(); + return 0; +} + +std::vector MEDCouplingMultiFields::getDirectChildren() const +{ + std::vector ret; + for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_fs.begin();it!=_fs.end();it++) + { + const MEDCouplingFieldDouble *curF(*it); + if(curF) + ret.push_back(const_cast(curF)); + } return ret; } diff --git a/src/MEDCoupling/MEDCouplingMultiFields.hxx b/src/MEDCoupling/MEDCouplingMultiFields.hxx index ad36e6627..d770576e2 100644 --- a/src/MEDCoupling/MEDCouplingMultiFields.hxx +++ b/src/MEDCoupling/MEDCouplingMultiFields.hxx @@ -59,7 +59,8 @@ namespace ParaMEDMEM virtual std::vector getArrays() const throw(INTERP_KERNEL::Exception); virtual std::vector getDifferentArrays(std::vector< std::vector >& refs) const throw(INTERP_KERNEL::Exception); void updateTime() const; - std::size_t getHeapMemorySize() const; + std::size_t getHeapMemorySizeWithoutChildren() const; + std::vector getDirectChildren() const; void getTinySerializationInformation(std::vector& tinyInfo, std::vector& tinyInfo2, int& nbOfDiffMeshes, int& nbOfDiffArr) const; void finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoD, const std::vector& ft, const std::vector& ms, diff --git a/src/MEDCoupling/MEDCouplingPointSet.cxx b/src/MEDCoupling/MEDCouplingPointSet.cxx index 50ae9094e..8c3fb4660 100644 --- a/src/MEDCoupling/MEDCouplingPointSet.cxx +++ b/src/MEDCoupling/MEDCouplingPointSet.cxx @@ -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 MEDCouplingPointSet::getDirectChildren() const +{ + std::vector ret; if(_coords) - ret+=_coords->getHeapMemorySize(); - return MEDCouplingMesh::getHeapMemorySize()+ret; + ret.push_back(const_cast(_coords)); + return ret; } void MEDCouplingPointSet::setCoords(const DataArrayDouble *coords) diff --git a/src/MEDCoupling/MEDCouplingPointSet.hxx b/src/MEDCoupling/MEDCouplingPointSet.hxx index 00d9a33b5..df12ac7b2 100644 --- a/src/MEDCoupling/MEDCouplingPointSet.hxx +++ b/src/MEDCoupling/MEDCouplingPointSet.hxx @@ -52,7 +52,8 @@ namespace ParaMEDMEM ~MEDCouplingPointSet(); public: void updateTime() const; - std::size_t getHeapMemorySize() const; + std::size_t getHeapMemorySizeWithoutChildren() const; + std::vector getDirectChildren() const; int getNumberOfNodes() const; int getSpaceDimension() const; void setCoords(const DataArrayDouble *coords); diff --git a/src/MEDCoupling/MEDCouplingRefCountObject.cxx b/src/MEDCoupling/MEDCouplingRefCountObject.cxx index 7f9f493f6..b2374b980 100644 --- a/src/MEDCoupling/MEDCouplingRefCountObject.cxx +++ b/src/MEDCoupling/MEDCouplingRefCountObject.cxx @@ -21,6 +21,8 @@ #include "MEDCouplingRefCountObject.hxx" #include "MED_version.h" +#include + 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 v(getDirectChildren()); + std::set s1,s2(v.begin(),v.end()); + while(!s2.empty()) + { + std::set s3; + for(std::set::const_iterator it=s2.begin();it!=s2.end();it++) + { + if(s1.find(*it)==s1.end()) + { + ret+=(*it)->getHeapMemorySizeWithoutChildren(); + s1.insert(*it); + std::vector v2((*it)->getDirectChildren()); + for(std::vector::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); diff --git a/src/MEDCoupling/MEDCouplingRefCountObject.hxx b/src/MEDCoupling/MEDCouplingRefCountObject.hxx index f5c99be4a..883f4599d 100644 --- a/src/MEDCoupling/MEDCouplingRefCountObject.hxx +++ b/src/MEDCoupling/MEDCouplingRefCountObject.hxx @@ -23,6 +23,7 @@ #include "MEDCoupling.hxx" +#include #include 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 getDirectChildren() const = 0; + MEDCOUPLING_EXPORT int getRCValue() const; + MEDCOUPLING_EXPORT RefCountObject& operator=(const RefCountObject& other); protected: virtual ~RefCountObject(); private: diff --git a/src/MEDCoupling/MEDCouplingStructuredMesh.cxx b/src/MEDCoupling/MEDCouplingStructuredMesh.cxx index 2c92df241..60b20c5ea 100644 --- a/src/MEDCoupling/MEDCouplingStructuredMesh.cxx +++ b/src/MEDCoupling/MEDCouplingStructuredMesh.cxx @@ -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) diff --git a/src/MEDCoupling/MEDCouplingStructuredMesh.hxx b/src/MEDCoupling/MEDCouplingStructuredMesh.hxx index a8cb2ef7c..004b728eb 100644 --- a/src/MEDCoupling/MEDCouplingStructuredMesh.hxx +++ b/src/MEDCoupling/MEDCouplingStructuredMesh.hxx @@ -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& 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 diff --git a/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx b/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx index 818f4eb71..7bc366262 100644 --- a/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx +++ b/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx @@ -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 MEDCouplingTimeDiscretization::getDirectChildren() const +{ + std::vector ret; if(_array) - ret+=_array->getHeapMemorySize(); + ret.push_back(const_cast(_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 MEDCouplingTwoTimeSteps::getDirectChildren() const +{ + std::vector ret(MEDCouplingTimeDiscretization::getDirectChildren()); if(_end_array) - ret+=_end_array->getHeapMemorySize(); - return MEDCouplingTimeDiscretization::getHeapMemorySize()+ret; + ret.push_back(const_cast(_end_array)); + return ret; } void MEDCouplingTwoTimeSteps::copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other) throw(INTERP_KERNEL::Exception) diff --git a/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx b/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx index 8cdbbe957..15641eabf 100644 --- a/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx +++ b/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx @@ -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 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 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); diff --git a/src/MEDCoupling/MEDCouplingUMesh.cxx b/src/MEDCoupling/MEDCouplingUMesh.cxx index 70fba21d9..53dd0d55f 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh.cxx @@ -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 MEDCouplingUMesh::getDirectChildren() const +{ + std::vector ret(MEDCouplingPointSet::getDirectChildren()); if(_nodal_connec) - ret+=_nodal_connec->getHeapMemorySize(); + ret.push_back(const_cast(_nodal_connec)); if(_nodal_connec_index) - ret+=_nodal_connec_index->getHeapMemorySize(); - return MEDCouplingPointSet::getHeapMemorySize()+ret; + ret.push_back(const_cast(_nodal_connec_index)); + return ret; } void MEDCouplingUMesh::updateTime() const diff --git a/src/MEDCoupling/MEDCouplingUMesh.hxx b/src/MEDCoupling/MEDCouplingUMesh.hxx index 4941812c2..4c75c0af5 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.hxx +++ b/src/MEDCoupling/MEDCouplingUMesh.hxx @@ -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 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; diff --git a/src/MEDLoader/MEDFileData.cxx b/src/MEDLoader/MEDFileData.cxx index 321aefa88..2c2646424 100644 --- a/src/MEDLoader/MEDFileData.cxx +++ b/src/MEDLoader/MEDFileData.cxx @@ -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 MEDFileData::getDirectChildren() const +{ + std::vector ret; if((const MEDFileFields *)_fields) - ret+=_fields->getHeapMemorySize(); + ret.push_back(const_cast((const MEDFileFields *)_fields)); if((const MEDFileMeshes *)_meshes) - ret+=_meshes->getHeapMemorySize(); + ret.push_back(const_cast((const MEDFileMeshes *)_meshes)); if((const MEDFileParameters *)_params) - ret+=_params->getHeapMemorySize(); + ret.push_back(const_cast((const MEDFileParameters *)_params)); return ret; + } MEDFileFields *MEDFileData::getFields() const diff --git a/src/MEDLoader/MEDFileData.hxx b/src/MEDLoader/MEDFileData.hxx index 2eb38e302..31411500e 100644 --- a/src/MEDLoader/MEDFileData.hxx +++ b/src/MEDLoader/MEDFileData.hxx @@ -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 getDirectChildren() const; MEDFileFields *getFields() const; MEDFileMeshes *getMeshes() const; MEDFileParameters *getParams() const; diff --git a/src/MEDLoader/MEDFileField.cxx b/src/MEDLoader/MEDFileField.cxx index b40a58df6..0a712f93c 100644 --- a/src/MEDLoader/MEDFileField.cxx +++ b/src/MEDLoader/MEDFileField.cxx @@ -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 MEDFileFieldLoc::getDirectChildren() const +{ + return std::vector(); +} + 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 MEDFileFieldPerMeshPerTypePerDisc::getDirectChildren() const +{ + return std::vector(); +} + MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::deepCpy(MEDFileFieldPerMeshPerType *father) const throw(INTERP_KERNEL::Exception) { MEDCouplingAutoRefCountObjectPtr 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); +} + +std::vector MEDFileFieldPerMeshPerType::getDirectChildren() const { - std::size_t ret=_field_pm_pt_pd.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr); + std::vector ret; for(std::vector< MEDCouplingAutoRefCountObjectPtr >::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(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 MEDFileFieldPerMesh::getDirectChildren() const +{ + std::vector 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(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)+_locs.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr); - for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_pfls.begin();it!=_pfls.end();it++) - ret+=(*it)->getHeapMemorySize(); + return _file_name.capacity()+_pfls.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr)+_locs.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr); +} + +std::vector MEDFileFieldGlobs::getDirectChildren() const +{ + std::vector 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(cur)); + } for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_locs.begin();it!=_locs.end();it++) - ret+=(*it)->getHeapMemorySize(); + { + const MEDFileFieldLoc *cur(*it); + if(cur) + ret.push_back(const_cast(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 MEDFileFieldGlobsReal::getDirectChildren() const { - std::size_t ret=0; + std::vector ret; if((const MEDFileFieldGlobs *)_globals) - ret+=_globals->getHeapMemorySize(); + ret.push_back(const_cast((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 MEDFileAnyTypeField1TSWithoutSDA::getDirectChildren() const +{ + std::vector ret; if(getUndergroundDataArray()) - ret+=getUndergroundDataArray()->getHeapMemorySize(); + ret.push_back(const_cast(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(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 MEDFileAnyTypeField1TS::getDirectChildren() const { - std::size_t ret=0; + std::vector ret(MEDFileFieldGlobsReal::getDirectChildren()); if((const MEDFileAnyTypeField1TSWithoutSDA *)_content) - ret+=_content->getHeapMemorySize(); - return ret+MEDFileFieldGlobsReal::getHeapMemorySize(); + ret.push_back(const_cast((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); + std::size_t ret(_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr)); for(std::vector::const_iterator it=_infos.begin();it!=_infos.end();it++) ret+=(*it).capacity(); + return ret; +} + +std::vector MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildren() const +{ + std::vector ret; for(std::vector< MEDCouplingAutoRefCountObjectPtr >::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(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 MEDFileAnyTypeFieldMultiTS::getDirectChildren() const { - std::size_t ret=0; - if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)_content) - ret+=_content->getHeapMemorySize(); - return ret+MEDFileFieldGlobsReal::getHeapMemorySize(); + std::vector ret(MEDFileFieldGlobsReal::getDirectChildren()); + if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content) + ret.push_back(const_cast((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); + return ret; +} + +std::vector MEDFileFields::getDirectChildren() const { - std::size_t ret=_fields.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr); + std::vector ret; for(std::vector< MEDCouplingAutoRefCountObjectPtr >::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(cur)); + } + return ret; } MEDFileFields *MEDFileFields::deepCpy() const throw(INTERP_KERNEL::Exception) diff --git a/src/MEDLoader/MEDFileField.hxx b/src/MEDLoader/MEDFileField.hxx index 9cb29b6fb..38a6ae1e5 100644 --- a/src/MEDLoader/MEDFileField.hxx +++ b/src/MEDLoader/MEDFileField.hxx @@ -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& refCoo, const std::vector& gsCoo, const std::vector& w); - std::size_t getHeapMemorySize() const; + std::size_t getHeapMemorySizeWithoutChildren() const; + std::vector 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 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 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 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 getDirectChildren() const; MEDFileFieldGlobs *deepCpy() const throw(INTERP_KERNEL::Exception); MEDFileFieldGlobs *shallowCpyPart(const std::vector& pfls, const std::vector& locs) const throw(INTERP_KERNEL::Exception); MEDFileFieldGlobs *deepCpyPart(const std::vector& pfls, const std::vector& 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 getDirectChildren() const; void simpleReprGlobs(std::ostream& oss) const; void resetContent(); void shallowCpyGlobs(const MEDFileFieldGlobsReal& other); @@ -482,7 +488,8 @@ namespace ParaMEDMEM const std::vector& getInfo() const; std::vector& getInfo(); void setInfo(const std::vector& infos) throw(INTERP_KERNEL::Exception); - std::size_t getHeapMemorySize() const; + std::size_t getHeapMemorySizeWithoutChildren() const; + std::vector 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 getDirectChildren() const; std::vector getPflsReallyUsed() const; std::vector getLocsReallyUsed() const; std::vector 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& 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 getDirectChildren() const; virtual MEDFileAnyTypeFieldMultiTSWithoutSDA *deepCpy() const throw(INTERP_KERNEL::Exception); virtual std::vector< MEDCouplingAutoRefCountObjectPtr > splitComponents() const throw(INTERP_KERNEL::Exception); virtual std::vector< MEDCouplingAutoRefCountObjectPtr > 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 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 > 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 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); diff --git a/src/MEDLoader/MEDFileFieldOverView.cxx b/src/MEDLoader/MEDFileFieldOverView.cxx index f0177647d..21f86e452 100644 --- a/src/MEDLoader/MEDFileFieldOverView.cxx +++ b/src/MEDLoader/MEDFileFieldOverView.cxx @@ -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 >::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 MEDFileMeshStruct::getDirectChildren() const +{ + return std::vector(); +} + MEDFileMeshStruct::MEDFileMeshStruct(const MEDFileMesh *mesh):_mesh(mesh) { std::vector 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 MEDMeshMultiLev::getDirectChildren() const +{ + return std::vector(); +} + MEDMeshMultiLev *MEDMeshMultiLev::New(const MEDFileMesh *m, const std::vector& 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 MEDFileField1TSStructItem2::getDirectChildren() const +{ + std::vector ret; const DataArrayInt *pfl(_pfl); if(pfl) - ret+=pfl->getHeapMemorySize(); - ret+=_loc.capacity(); + ret.push_back(const_cast(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 MEDFileField1TSStructItem::getDirectChildren() const +{ + std::vector 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(&(*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 MEDFileField1TSStruct::getDirectChildren() const +{ + std::vector ret; for(std::vector::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(&(*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)); + return ret; +} + +std::vector MEDFileFastCellSupportComparator::getDirectChildren() const +{ + std::vector ret; const MEDFileMeshStruct *mst(_mesh_comp); if(mst) - ret+=mst->getHeapMemorySize(); + ret.push_back(const_cast(mst)); for(std::vector< MEDCouplingAutoRefCountObjectPtr >::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(cur)); } - ret+=_f1ts_cmps.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr); return ret; } diff --git a/src/MEDLoader/MEDFileFieldOverView.hxx b/src/MEDLoader/MEDFileFieldOverView.hxx index 1201d8f59..9525e403a 100644 --- a/src/MEDLoader/MEDFileFieldOverView.hxx +++ b/src/MEDLoader/MEDFileFieldOverView.hxx @@ -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 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 getDirectChildren() const; public: static MEDMeshMultiLev *New(const MEDFileMesh *m, const std::vector& gts, const std::vector& pfls, const std::vector& nbEntities) throw(INTERP_KERNEL::Exception); static MEDMeshMultiLev *New(const MEDFileMesh *m, const std::vector& 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 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 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 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 getDirectChildren() const; private: MEDFileFastCellSupportComparator(const MEDFileMeshStruct *m, const MEDFileAnyTypeFieldMultiTS *ref); private: diff --git a/src/MEDLoader/MEDFileMesh.cxx b/src/MEDLoader/MEDFileMesh.cxx index 0eeecf37d..d6f11e227 100644 --- a/src/MEDLoader/MEDFileMesh.cxx +++ b/src/MEDLoader/MEDFileMesh.cxx @@ -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 >::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 MEDFileMesh::getDirectChildren() const +{ + return std::vector(); +} + /*! * 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)); + return ret; +} + +std::vector MEDFileUMesh::getDirectChildren() const +{ + std::vector ret(MEDFileMesh::getDirectChildren()); if((const DataArrayDouble*)_coords) - ret+=_coords->getHeapMemorySize(); + ret.push_back(const_cast((const DataArrayDouble*)_coords)); if((const DataArrayInt *)_fam_coords) - ret+=_fam_coords->getHeapMemorySize(); + ret.push_back(const_cast((const DataArrayInt *)_fam_coords)); if((const DataArrayInt *)_num_coords) - ret+=_num_coords->getHeapMemorySize(); + ret.push_back(const_cast((const DataArrayInt *)_num_coords)); if((const DataArrayInt *)_rev_num_coords) - ret+=_rev_num_coords->getHeapMemorySize(); + ret.push_back(const_cast((const DataArrayInt *)_rev_num_coords)); if((const DataArrayAsciiChar *)_name_coords) - ret+=_name_coords->getHeapMemorySize(); - ret+=_ms.capacity()*(sizeof(MEDCouplingAutoRefCountObjectPtr)); + ret.push_back(const_cast((const DataArrayAsciiChar *)_name_coords)); for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_ms.begin();it!=_ms.end();it++) if((const MEDFileUMeshSplitL1*) *it) - ret+=(*it)->getHeapMemorySize(); + ret.push_back(const_cast((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 MEDFileStructuredMesh::getDirectChildren() const +{ + std::vector ret(MEDFileMesh::getDirectChildren()); + if((const DataArrayInt *)_fam_nodes) + ret.push_back(const_cast((const DataArrayInt *)_fam_nodes)); + if((const DataArrayInt *)_num_nodes) + ret.push_back(const_cast((const DataArrayInt *)_num_nodes)); + if((const DataArrayInt *)_fam_cells) + ret.push_back(const_cast((const DataArrayInt *)_fam_cells)); + if((const DataArrayInt *)_num_cells) + ret.push_back(const_cast((const DataArrayInt *)_num_nodes)); + if((const DataArrayInt *)_rev_num_nodes) + ret.push_back(const_cast((const DataArrayInt *)_rev_num_nodes)); + if((const DataArrayInt *)_rev_num_cells) + ret.push_back(const_cast((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 MEDFileCMesh::getDirectChildren() const +{ + std::vector ret(MEDFileStructuredMesh::getDirectChildren()); if((const MEDCouplingCMesh *)_cmesh) - ret+=_cmesh->getHeapMemorySize(); + ret.push_back(const_cast((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 MEDFileCurveLinearMesh::getDirectChildren() const { - std::size_t ret=MEDFileStructuredMesh::getHeapMemorySize(); + std::vector ret(MEDFileStructuredMesh::getDirectChildren()); if((const MEDCouplingCurveLinearMesh *)_clmesh) - ret+=_clmesh->getHeapMemorySize(); + ret.push_back(const_cast((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); +} + +std::vector MEDFileMeshMultiTS::getDirectChildren() const { - std::size_t ret=_mesh_one_ts.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr); + std::vector ret; for(std::vector< MEDCouplingAutoRefCountObjectPtr >::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(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)); +} + +std::vector MEDFileMeshes::getDirectChildren() const { - std::size_t ret=_meshes.capacity()*(sizeof(MEDCouplingAutoRefCountObjectPtr)); + std::vector ret; for(std::vector< MEDCouplingAutoRefCountObjectPtr >::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(cur)); + } + return ret; } std::string MEDFileMeshes::simpleRepr() const diff --git a/src/MEDLoader/MEDFileMesh.hxx b/src/MEDLoader/MEDFileMesh.hxx index ba03076bb..742ad47c7 100644 --- a/src/MEDLoader/MEDFileMesh.hxx +++ b/src/MEDLoader/MEDFileMesh.hxx @@ -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 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 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 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 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 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 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 >& 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 getDirectChildren() const; std::string simpleRepr() const; void simpleReprWithoutHeader(std::ostream& oss) const; void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception); diff --git a/src/MEDLoader/MEDFileMeshElt.cxx b/src/MEDLoader/MEDFileMeshElt.cxx index 0725d6890..5bad3f8d9 100644 --- a/src/MEDLoader/MEDFileMeshElt.cxx +++ b/src/MEDLoader/MEDFileMeshElt.cxx @@ -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 MEDFileUMeshPerType::getDirectChildren() const +{ + std::vector ret; + if((const MEDCoupling1GTUMesh *)_m) + ret.push_back(const_cast((const MEDCoupling1GTUMesh *)_m)); + if((const DataArrayInt *)_num) + ret.push_back(const_cast((const DataArrayInt *)_num)); + if((const DataArrayInt *)_fam) + ret.push_back(const_cast((const DataArrayInt *)_fam)); + if((const DataArrayAsciiChar *)_names) + ret.push_back(const_cast((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}; diff --git a/src/MEDLoader/MEDFileMeshElt.hxx b/src/MEDLoader/MEDFileMeshElt.hxx index af728268a..ee3ccda98 100644 --- a/src/MEDLoader/MEDFileMeshElt.hxx +++ b/src/MEDLoader/MEDFileMeshElt.hxx @@ -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 getDirectChildren() const; int getDim() const; MEDCoupling1GTUMesh *getMesh() const { return const_cast((const MEDCoupling1GTUMesh *)_m); } const DataArrayInt *getFam() const { return _fam; } diff --git a/src/MEDLoader/MEDFileMeshLL.cxx b/src/MEDLoader/MEDFileMeshLL.cxx index a4722e9b4..ad8c2dae0 100644 --- a/src/MEDLoader/MEDFileMeshLL.cxx +++ b/src/MEDLoader/MEDFileMeshLL.cxx @@ -40,6 +40,16 @@ MEDFileMeshL2::MEDFileMeshL2():_name(MED_NAME_SIZE),_description(MED_COMMENT_SIZ { } +std::size_t MEDFileMeshL2::getHeapMemorySizeWithoutChildren() const +{ + return 0; +} + +std::vector MEDFileMeshL2::getDirectChildren() const +{ + return std::vector(); +} + 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 MEDFileUMeshSplitL1::getDirectChildren() const +{ + std::vector ret; + ret.push_back(const_cast(&_m_by_types)); if((const DataArrayInt*)_fam) - ret+=_fam->getHeapMemorySize(); + ret.push_back(const_cast((const DataArrayInt*)_fam)); if((const DataArrayInt*)_num) - ret+=_num->getHeapMemorySize(); + ret.push_back(const_cast((const DataArrayInt*)_num)); if((const DataArrayInt*)_rev_num) - ret+=_rev_num->getHeapMemorySize(); + ret.push_back(const_cast((const DataArrayInt*)_rev_num)); if((const DataArrayAsciiChar*)_names) - ret+=_names->getHeapMemorySize(); + ret.push_back(const_cast((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); - std::size_t sz(_m_parts.size()); - for(std::size_t i=0;i)); + return ret; +} + +std::vector MEDFileUMeshAggregateCompute::getDirectChildren() const +{ + std::vector ret; + for(std::vector< MEDCouplingAutoRefCountObjectPtr >::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(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(m)); return ret; } diff --git a/src/MEDLoader/MEDFileMeshLL.hxx b/src/MEDLoader/MEDFileMeshLL.hxx index 56e19db6f..a44312b40 100644 --- a/src/MEDLoader/MEDFileMeshLL.hxx +++ b/src/MEDLoader/MEDFileMeshLL.hxx @@ -42,7 +42,8 @@ namespace ParaMEDMEM { public: MEDFileMeshL2(); - std::size_t getHeapMemorySize() const { return 0; } + std::size_t getHeapMemorySizeWithoutChildren() const; + std::vector 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 _m; }; - class MEDFileUMeshAggregateCompute + class MEDFileUMeshAggregateCompute : public RefCountObject { public: MEDFileUMeshAggregateCompute(); @@ -147,7 +148,8 @@ namespace ParaMEDMEM std::vector 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 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 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; diff --git a/src/MEDLoader/MEDFileParameter.cxx b/src/MEDLoader/MEDFileParameter.cxx index 09536b60c..ad675d51f 100644 --- a/src/MEDLoader/MEDFileParameter.cxx +++ b/src/MEDLoader/MEDFileParameter.cxx @@ -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 MEDFileParameterDouble1TSWTI::getDirectChildren() const +{ + return std::vector(); +} + 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 MEDFileParameterDouble1TS::getDirectChildren() const +{ + return std::vector(); +} + 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)*_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)*_param_per_ts.capacity(); + return ret; +} + +std::vector MEDFileParameterMultiTS::getDirectChildren() const +{ + std::vector ret; + for(std::vector< MEDCouplingAutoRefCountObjectPtr >::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(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)*_params.capacity(); - for(std::size_t i=0;i<_params.size();i++) + std::size_t ret(sizeof(MEDFileParameters)); + ret+=sizeof(MEDCouplingAutoRefCountObjectPtr)*_params.capacity(); + return ret; +} + +std::vector MEDFileParameters::getDirectChildren() const +{ + std::vector ret; + for(std::vector< MEDCouplingAutoRefCountObjectPtr >::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(elt)); } - return ret2+ret; + return ret; } MEDFileParameters *MEDFileParameters::deepCpy() const throw(INTERP_KERNEL::Exception) diff --git a/src/MEDLoader/MEDFileParameter.hxx b/src/MEDLoader/MEDFileParameter.hxx index cb4c6fad1..21240cb0b 100644 --- a/src/MEDLoader/MEDFileParameter.hxx +++ b/src/MEDLoader/MEDFileParameter.hxx @@ -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 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 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 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 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); diff --git a/src/MEDLoader/SauvReader.cxx b/src/MEDLoader/SauvReader.cxx index fcbbd5ef2..65093499c 100644 --- a/src/MEDLoader/SauvReader.cxx +++ b/src/MEDLoader/SauvReader.cxx @@ -81,6 +81,16 @@ SauvReader::~SauvReader() _fileReader->decrRef(); } +std::size_t SauvReader::getHeapMemorySizeWithoutChildren() const +{ + return 0; +} + +std::vector SauvReader::getDirectChildren() const +{ + return std::vector(); +} + //================================================================================ /*! * \brief Return current line of ASCII file to report an error diff --git a/src/MEDLoader/SauvReader.hxx b/src/MEDLoader/SauvReader.hxx index d2d52cc62..01b87d08e 100644 --- a/src/MEDLoader/SauvReader.hxx +++ b/src/MEDLoader/SauvReader.hxx @@ -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 getDirectChildren() const; void readRecord2(); void readRecord4(); void readRecord7(); diff --git a/src/MEDLoader/SauvUtilities.hxx b/src/MEDLoader/SauvUtilities.hxx index f16ba02c1..25bec6d3b 100644 --- a/src/MEDLoader/SauvUtilities.hxx +++ b/src/MEDLoader/SauvUtilities.hxx @@ -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 getDirectChildren() const { return std::vector(); } protected: std::string _fileName, _curLocale; int _iRead, _nbToRead; diff --git a/src/MEDLoader/SauvWriter.cxx b/src/MEDLoader/SauvWriter.cxx index 4a2105620..908f7a504 100644 --- a/src/MEDLoader/SauvWriter.cxx +++ b/src/MEDLoader/SauvWriter.cxx @@ -223,6 +223,16 @@ SauvWriter* SauvWriter::New() return new SauvWriter; } +std::size_t SauvWriter::getHeapMemorySizeWithoutChildren() const +{ + return 0; +} + +std::vector SauvWriter::getDirectChildren() const +{ + return std::vector(); +} + //================================================================================ /*! * \brief Fills own DS by MEDFileData diff --git a/src/MEDLoader/SauvWriter.hxx b/src/MEDLoader/SauvWriter.hxx index 3f935aab8..7f3b13fde 100644 --- a/src/MEDLoader/SauvWriter.hxx +++ b/src/MEDLoader/SauvWriter.hxx @@ -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 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.