mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-05 18:16:23 +03:00
0030901: Visualization - OSD_MemInfo moving memory computation out of the constructor
This commit is contained in:
parent
c64135f723
commit
0be11733a7
@ -41,9 +41,29 @@
|
||||
// function : OSD_MemInfo
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
OSD_MemInfo::OSD_MemInfo()
|
||||
OSD_MemInfo::OSD_MemInfo (const Standard_Boolean theImmediateUpdate)
|
||||
{
|
||||
Update();
|
||||
if (theImmediateUpdate)
|
||||
{
|
||||
Update();
|
||||
}
|
||||
else
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// =======================================================================
|
||||
// function : Clear
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OSD_MemInfo::Clear()
|
||||
{
|
||||
for (Standard_Integer anIter = 0; anIter < MemCounter_NB; ++anIter)
|
||||
{
|
||||
myCounters[anIter] = Standard_Size(-1);
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@ -52,11 +72,7 @@ OSD_MemInfo::OSD_MemInfo()
|
||||
// =======================================================================
|
||||
void OSD_MemInfo::Update()
|
||||
{
|
||||
// reset values
|
||||
for (Standard_Integer anIter = 0; anIter < MemCounter_NB; ++anIter)
|
||||
{
|
||||
myCounters[anIter] = Standard_Size(-1);
|
||||
}
|
||||
Clear();
|
||||
#ifndef OCCT_UWP
|
||||
#if defined(_WIN32)
|
||||
#if (_WIN32_WINNT >= 0x0500)
|
||||
@ -237,6 +253,20 @@ Standard_Size OSD_MemInfo::ValueMiB (const OSD_MemInfo::Counter theCounter) cons
|
||||
? 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 :
|
||||
|
@ -66,7 +66,10 @@ public:
|
||||
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();
|
||||
@ -74,16 +77,21 @@ public:
|
||||
//! 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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user