Open CASCADE Technology 7.8.2.dev
OSD_MemInfo Class Reference

This class provide information about memory utilized by current process. This information includes: More...

#include <OSD_MemInfo.hxx>

Public Types

enum  Counter {
  MemPrivate = 0 , MemVirtual , MemWorkingSet , MemWorkingSetPeak ,
  MemSwapUsage , MemSwapUsagePeak , MemHeapUsage , MemCounter_NB
}
 

Public Member Functions

 OSD_MemInfo (const Standard_Boolean theImmediateUpdate=Standard_True)
 Create and initialize. By default all countes are active.
 
Standard_Boolean IsActive (const OSD_MemInfo::Counter theCounter) const
 Return true if the counter is active.
 
void SetActive (const Standard_Boolean theActive)
 Set all counters active. The information is collected for active counters.
 
void SetActive (const OSD_MemInfo::Counter theCounter, const Standard_Boolean theActive)
 Set the counter active. The information is collected for active counters.
 
void Clear ()
 Clear counters.
 
void Update ()
 Update counters.
 
TCollection_AsciiString ToString () const
 Return the string representation for all available counter.
 
Standard_Size Value (const OSD_MemInfo::Counter theCounter) const
 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_Size ValueMiB (const OSD_MemInfo::Counter theCounter) const
 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_Real ValuePreciseMiB (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.
 

Static Public Member Functions

static TCollection_AsciiString PrintInfo ()
 Return the string representation for all available counter.
 

Protected Member Functions

Standard_Boolean hasValue (const OSD_MemInfo::Counter theCounter) const
 Return true if the counter is active and the value is valid.
 

Detailed Description

This class provide information about memory utilized by current process. This information includes:

  • Private Memory - synthetic value that tries to filter out the memory usage only by the process itself (allocated for data and stack), excluding dynamic libraries. These pages may be in RAM or in SWAP.
  • Virtual Memory - amount of reserved and committed memory in the user-mode portion of the virtual address space. Notice that this counter includes reserved memory (not yet in used) and shared between processes memory (libraries).
  • Working Set - set of memory pages in the virtual address space of the process that are currently resident in physical memory (RAM). These pages are available for an application to use without triggering a page fault.
  • Pagefile Usage - space allocated for the pagefile, in bytes. Those pages may or may not be in memory (RAM) thus this counter couldn't be used to estimate how many active pages doesn't present in RAM.

Notice that none of these counters can be used as absolute measure of application memory consumption!

User should analyze all values in specific case to make correct decision about memory (over)usage. This is also preferred to use specialized tools to detect memory leaks.

This also means that these values should not be used for intellectual memory management by application itself.

Member Enumeration Documentation

◆ Counter

Enumerator
MemPrivate 

Virtual memory allocated for data and stack excluding libraries.

MemVirtual 

Reserved and committed memory of the virtual address space.

MemWorkingSet 

Memory pages that are currently resident in physical memory.

MemWorkingSetPeak 

Peak working set size.

MemSwapUsage 

Space allocated for the pagefile.

MemSwapUsagePeak 

Peak space allocated for the pagefile.

MemHeapUsage 

Total space allocated from the heap.

MemCounter_NB 

Indicates total counters number.

Constructor & Destructor Documentation

◆ OSD_MemInfo()

OSD_MemInfo::OSD_MemInfo ( const Standard_Boolean theImmediateUpdate = Standard_True)

Create and initialize. By default all countes are active.

Member Function Documentation

◆ Clear()

void OSD_MemInfo::Clear ( )

Clear counters.

◆ hasValue()

Standard_Boolean OSD_MemInfo::hasValue ( const OSD_MemInfo::Counter theCounter) const
inlineprotected

Return true if the counter is active and the value is valid.

◆ IsActive()

Standard_Boolean OSD_MemInfo::IsActive ( const OSD_MemInfo::Counter theCounter) const
inline

Return true if the counter is active.

◆ PrintInfo()

static TCollection_AsciiString OSD_MemInfo::PrintInfo ( )
static

Return the string representation for all available counter.

◆ SetActive() [1/2]

void OSD_MemInfo::SetActive ( const OSD_MemInfo::Counter theCounter,
const Standard_Boolean theActive )
inline

Set the counter active. The information is collected for active counters.

Parameters
theCountertype of counter
theActivestate for the counter

◆ SetActive() [2/2]

void OSD_MemInfo::SetActive ( const Standard_Boolean theActive)

Set all counters active. The information is collected for active counters.

Parameters
theActivestate for counters

◆ ToString()

TCollection_AsciiString OSD_MemInfo::ToString ( ) const

Return the string representation for all available counter.

◆ Update()

void OSD_MemInfo::Update ( )

Update counters.

◆ Value()

Standard_Size OSD_MemInfo::Value ( const OSD_MemInfo::Counter theCounter) const

Return value of specified counter in bytes. Notice that NOT all counters are available on various systems. Standard_Size(-1) means invalid (unavailable) value.

◆ ValueMiB()

Standard_Size OSD_MemInfo::ValueMiB ( const OSD_MemInfo::Counter theCounter) const

Return value of specified counter in MiB. Notice that NOT all counters are available on various systems. Standard_Size(-1) means invalid (unavailable) value.

◆ ValuePreciseMiB()

Standard_Real OSD_MemInfo::ValuePreciseMiB ( 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.


The documentation for this class was generated from the following file: