#include "MED_version.h"
#include <sstream>
-#include <set>
using namespace ParaMEDMEM;
std::size_t ret(getHeapMemorySizeWithoutChildren());
std::vector<const BigMemoryObject *> v(getDirectChildren());
std::set<const BigMemoryObject *> s1,s2(v.begin(),v.end());
+ return ret+GetHeapMemoryOfSet(s1,s2);
+}
+
+std::size_t BigMemoryObject::GetHeapMemorySizeOfObjs(const std::vector<const BigMemoryObject *>& objs)
+{
+ std::size_t ret(0);
+ std::set<const BigMemoryObject *> s1,s2;
+ for(std::vector<const BigMemoryObject *>::const_iterator it0=objs.begin();it0!=objs.end();it0++)
+ {
+ if(*it0)
+ if(s1.find(*it0)==s1.end())
+ {
+ std::vector<const BigMemoryObject *> vTmp((*it0)->getDirectChildren());
+ s2.insert(vTmp.begin(),vTmp.end());
+ ret+=(*it0)->getHeapMemorySizeWithoutChildren();
+ s1.insert(*it0);
+ }
+ }
+ return ret+GetHeapMemoryOfSet(s1,s2);
+}
+
+std::size_t BigMemoryObject::GetHeapMemoryOfSet(std::set<const BigMemoryObject *>& s1, std::set<const BigMemoryObject *>& s2)
+{
+ std::size_t ret(0);
while(!s2.empty())
{
std::set<const BigMemoryObject *> s3;
#include "MEDCoupling.hxx"
+#include <set>
#include <vector>
#include <string>
#include <cstddef>
public:
MEDCOUPLING_EXPORT std::size_t getHeapMemorySize() const;
MEDCOUPLING_EXPORT std::string getHeapMemorySizeStr() const;
+ MEDCOUPLING_EXPORT static std::size_t GetHeapMemorySizeOfObjs(const std::vector<const BigMemoryObject *>& objs);
MEDCOUPLING_EXPORT virtual std::size_t getHeapMemorySizeWithoutChildren() const = 0;
MEDCOUPLING_EXPORT virtual std::vector<const BigMemoryObject *> getDirectChildren() const = 0;
MEDCOUPLING_EXPORT virtual ~BigMemoryObject();
+ private:
+ static std::size_t GetHeapMemoryOfSet(std::set<const BigMemoryObject *>& s1, std::set<const BigMemoryObject *>& s2);
};
class RefCountObjectOnly
class BigMemoryObject
{
public:
- std::size_t getHeapMemorySize() const;
- std::string getHeapMemorySizeStr() const;
- virtual std::size_t getHeapMemorySizeWithoutChildren() const;
+ std::size_t getHeapMemorySize() const throw(INTERP_KERNEL::Exception);
+ std::string getHeapMemorySizeStr() const throw(INTERP_KERNEL::Exception);
+ virtual std::size_t getHeapMemorySizeWithoutChildren() const throw(INTERP_KERNEL::Exception);
virtual ~BigMemoryObject();
%extend
{
- virtual PyObject *getDirectChildren() const
+ virtual PyObject *getDirectChildren() const throw(INTERP_KERNEL::Exception)
{
std::vector<const BigMemoryObject *> c(self->getDirectChildren());
PyObject *ret(PyList_New(c.size()));
PyList_SetItem(ret,i,SWIG_NewPointerObj(SWIG_as_voidptr(c[i]),SWIGTYPE_p_ParaMEDMEM__BigMemoryObject, 0 | 0 ));
return ret;
}
+
+ static std::size_t GetHeapMemorySizeOfObjs(PyObject *objs) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<const BigMemoryObject *> cppObjs;
+ convertFromPyObjVectorOfObj<const ParaMEDMEM::BigMemoryObject *>(objs,SWIGTYPE_p_ParaMEDMEM__BigMemoryObject,"BigMemoryObject",cppObjs);
+ return BigMemoryObject::GetHeapMemorySizeOfObjs(cppObjs);
+ }
}
};