// function : OSD_MemInfo
// purpose :
// =======================================================================
-OSD_MemInfo::OSD_MemInfo()
+OSD_MemInfo::OSD_MemInfo (const Standard_Boolean theImmediateUpdate)
{
- Update();
+ if (theImmediateUpdate)
+ {
+ Update();
+ }
+ else
+ {
+ Clear();
+ }
}
+
// =======================================================================
-// function : Update
+// function : Clear
// purpose :
// =======================================================================
-void OSD_MemInfo::Update()
+void OSD_MemInfo::Clear()
{
- // reset values
for (Standard_Integer anIter = 0; anIter < MemCounter_NB; ++anIter)
{
myCounters[anIter] = Standard_Size(-1);
}
+}
+
+// =======================================================================
+// function : Update
+// purpose :
+// =======================================================================
+void OSD_MemInfo::Update()
+{
+ Clear();
#ifndef OCCT_UWP
#if defined(_WIN32)
#if (_WIN32_WINNT >= 0x0500)
? Standard_Size(-1) : (myCounters[theCounter] / (1024 * 1024));
}
+// =======================================================================
+// function : ValuePreciseMiB
+// purpose :
+// =======================================================================
+Standard_Real OSD_MemInfo::ValuePreciseMiB (const OSD_MemInfo::Counter theCounter) const
+{
+ if (theCounter < 0 || theCounter >= MemCounter_NB)
+ {
+ return -1.0;
+ }
+ return (myCounters[theCounter] == Standard_Size(-1))
+ ? -1.0 : ((Standard_Real )myCounters[theCounter] / (1024.0 * 1024.0));
+}
+
// =======================================================================
// function : ShowInfo
// purpose :
public:
//! Create and initialize
- Standard_EXPORT OSD_MemInfo();
+ Standard_EXPORT OSD_MemInfo (const Standard_Boolean theImmediateUpdate = Standard_True);
+
+ //! Clear counters
+ Standard_EXPORT void Clear();
//! Update counters
Standard_EXPORT void Update();
//! Return the string representation for all available counter.
Standard_EXPORT TCollection_AsciiString ToString() const;
- //! Return value or specified counter in bytes.
+ //! Return value of specified counter in bytes.
//! Notice that NOT all counters are available on various systems.
//! Standard_Size(-1) means invalid (unavailable) value.
Standard_EXPORT Standard_Size Value (const OSD_MemInfo::Counter theCounter) const;
- //! Return value or specified counter in MiB.
+ //! Return value of 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;
+ //! Return floating value of specified counter in MiB.
+ //! Notice that NOT all counters are available on various systems.
+ //! Standard_Real(-1) means invalid (unavailable) value.
+ Standard_EXPORT Standard_Real ValuePreciseMiB (const OSD_MemInfo::Counter theCounter) const;
+
public:
//! Return the string representation for all available counter.