1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-03 14:10:33 +03:00

0030901: Visualization - OSD_MemInfo moving memory computation out of the constructor

This commit is contained in:
nds
2019-08-15 08:40:14 +03:00
parent b7949b1dca
commit a8959620a2
4 changed files with 11 additions and 5 deletions

View File

@@ -763,6 +763,7 @@ static int dmeminfo (Draw_Interpretor& theDI,
const char** theArgVec) const char** theArgVec)
{ {
OSD_MemInfo aMemInfo; OSD_MemInfo aMemInfo;
aMemTool.Update();
if (theArgNb <= 1) if (theArgNb <= 1)
{ {
theDI << aMemInfo.ToString(); theDI << aMemInfo.ToString();

View File

@@ -43,7 +43,11 @@
// ======================================================================= // =======================================================================
OSD_MemInfo::OSD_MemInfo() OSD_MemInfo::OSD_MemInfo()
{ {
Update(); // reset values
for (Standard_Integer anIter = 0; anIter < MemCounter_NB; ++anIter)
{
myCounters[anIter] = Standard_Size(-1);
}
} }
// ======================================================================= // =======================================================================
@@ -227,14 +231,14 @@ Standard_Size OSD_MemInfo::Value (const OSD_MemInfo::Counter theCounter) const
// function : ValueMiB // function : ValueMiB
// purpose : // purpose :
// ======================================================================= // =======================================================================
Standard_Size OSD_MemInfo::ValueMiB (const OSD_MemInfo::Counter theCounter) const Standard_Real OSD_MemInfo::ValueMiB (const OSD_MemInfo::Counter theCounter) const
{ {
if (theCounter < 0 || theCounter >= MemCounter_NB) if (theCounter < 0 || theCounter >= MemCounter_NB)
{ {
return Standard_Size(-1); return Standard_Real(-1.);
} }
return (myCounters[theCounter] == Standard_Size(-1)) return (myCounters[theCounter] == Standard_Size(-1))
? Standard_Size(-1) : (myCounters[theCounter] / (1024 * 1024)); ? Standard_Real(-1.) : ((Standard_Real)myCounters[theCounter] / (1024 * 1024));
} }
// ======================================================================= // =======================================================================

View File

@@ -82,7 +82,7 @@ public:
//! Return value or specified counter in MiB. //! Return value or specified counter in MiB.
//! Notice that NOT all counters are available on various systems. //! Notice that NOT all counters are available on various systems.
//! Standard_Size(-1) means invalid (unavailable) value. //! Standard_Size(-1) means invalid (unavailable) value.
Standard_EXPORT Standard_Size ValueMiB (const OSD_MemInfo::Counter theCounter) const; Standard_EXPORT Standard_Real ValueMiB (const OSD_MemInfo::Counter theCounter) const;
public: public:

View File

@@ -2786,6 +2786,7 @@ template<typename T> void AllocDummyArr (Draw_Interpretor& theDI, int theN1, int
NCollection_Array1<T> aMapArr1(0, theN1), aMapArr2(0, theN2); NCollection_Array1<T> aMapArr1(0, theN1), aMapArr2(0, theN2);
OSD_MemInfo aMemTool; OSD_MemInfo aMemTool;
aMemTool.Update();
Standard_Size aMem0 = aMemTool.Value (OSD_MemInfo::MemHeapUsage); Standard_Size aMem0 = aMemTool.Value (OSD_MemInfo::MemHeapUsage);
for (int i = 1; i < theN1; i++) for (int i = 1; i < theN1; i++)