From a8959620a2408e5cced47957aae23e48ba4a5505 Mon Sep 17 00:00:00 2001 From: nds Date: Thu, 15 Aug 2019 08:40:14 +0300 Subject: [PATCH] 0030901: Visualization - OSD_MemInfo moving memory computation out of the constructor --- src/Draw/Draw_BasicCommands.cxx | 1 + src/OSD/OSD_MemInfo.cxx | 12 ++++++++---- src/OSD/OSD_MemInfo.hxx | 2 +- src/QABugs/QABugs_20.cxx | 1 + 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/Draw/Draw_BasicCommands.cxx b/src/Draw/Draw_BasicCommands.cxx index 638fcfdd9d..96f0ba634b 100644 --- a/src/Draw/Draw_BasicCommands.cxx +++ b/src/Draw/Draw_BasicCommands.cxx @@ -763,6 +763,7 @@ static int dmeminfo (Draw_Interpretor& theDI, const char** theArgVec) { OSD_MemInfo aMemInfo; + aMemTool.Update(); if (theArgNb <= 1) { theDI << aMemInfo.ToString(); diff --git a/src/OSD/OSD_MemInfo.cxx b/src/OSD/OSD_MemInfo.cxx index d5eda9ee26..04c883a2c7 100644 --- a/src/OSD/OSD_MemInfo.cxx +++ b/src/OSD/OSD_MemInfo.cxx @@ -43,7 +43,11 @@ // ======================================================================= 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 // 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) { - return Standard_Size(-1); + return Standard_Real(-1.); } return (myCounters[theCounter] == Standard_Size(-1)) - ? Standard_Size(-1) : (myCounters[theCounter] / (1024 * 1024)); + ? Standard_Real(-1.) : ((Standard_Real)myCounters[theCounter] / (1024 * 1024)); } // ======================================================================= diff --git a/src/OSD/OSD_MemInfo.hxx b/src/OSD/OSD_MemInfo.hxx index e1def2dc3d..40633e00f6 100644 --- a/src/OSD/OSD_MemInfo.hxx +++ b/src/OSD/OSD_MemInfo.hxx @@ -82,7 +82,7 @@ public: //! Return value or specified counter in MiB. //! Notice that NOT all counters are available on various systems. //! 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: diff --git a/src/QABugs/QABugs_20.cxx b/src/QABugs/QABugs_20.cxx index 7b676e5e84..93a04ae4fe 100644 --- a/src/QABugs/QABugs_20.cxx +++ b/src/QABugs/QABugs_20.cxx @@ -2786,6 +2786,7 @@ template void AllocDummyArr (Draw_Interpretor& theDI, int theN1, int NCollection_Array1 aMapArr1(0, theN1), aMapArr2(0, theN2); OSD_MemInfo aMemTool; + aMemTool.Update(); Standard_Size aMem0 = aMemTool.Value (OSD_MemInfo::MemHeapUsage); for (int i = 1; i < theN1; i++) -- 2.39.5