1 // Created on: 2011-10-05
2 // Created by: Kirill GAVRILOV
3 // Copyright (c) 2013-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _OSD_MemInfo_H__
17 #define _OSD_MemInfo_H__
19 #include <TCollection_AsciiString.hxx>
21 //! This class provide information about memory utilized by current process.
22 //! This information includes:
23 //! - Private Memory - synthetic value that tries to filter out the memory
24 //! usage only by the process itself (allocated for data
25 //! and stack), excluding dynamic libraries.
26 //! These pages may be in RAM or in SWAP.
27 //! - Virtual Memory - amount of reserved and committed memory in the
28 //! user-mode portion of the virtual address space.
29 //! Notice that this counter includes reserved memory
30 //! (not yet in used) and shared between processes memory (libraries).
31 //! - Working Set - set of memory pages in the virtual address space of the process
32 //! that are currently resident in physical memory (RAM).
33 //! These pages are available for an application to use
34 //! without triggering a page fault.
35 //! - Pagefile Usage - space allocated for the pagefile, in bytes.
36 //! Those pages may or may not be in memory (RAM)
37 //! thus this counter couldn't be used to estimate
38 //! how many active pages doesn't present in RAM.
40 //! Notice that none of these counters can be used as absolute measure of
41 //! application memory consumption!
43 //! User should analyze all values in specific case to make correct decision
44 //! about memory (over)usage. This is also prefferred to use specialized
45 //! tools to detect memory leaks.
47 //! This also means that these values should not be used for intellectual
48 //! memory management by application itself.
56 MemPrivate = 0, //!< Virtual memory allocated for data and stack excluding libraries
57 MemVirtual, //!< Reserved and committed memory of the virtual address space
58 MemWorkingSet, //!< Memory pages that are currently resident in physical memory
59 MemWorkingSetPeak, //!< Peak working set size
60 MemSwapUsage, //!< Space allocated for the pagefile
61 MemSwapUsagePeak, //!< Peak space allocated for the pagefile
62 MemHeapUsage, //!< Total space allocated from the heap
63 MemCounter_NB //!< Indicates total counters number
68 //! Create and initialize
69 Standard_EXPORT OSD_MemInfo();
72 Standard_EXPORT void Update();
74 //! Return the string representation for all available counter.
75 Standard_EXPORT TCollection_AsciiString ToString() const;
77 //! Return value or specified counter in bytes.
78 //! Notice that NOT all counters are available on various systems.
79 //! Standard_Size(-1) means invalid (unavailable) value.
80 Standard_EXPORT Standard_Size Value (const OSD_MemInfo::Counter theCounter) const;
82 //! Return value or specified counter in MiB.
83 //! Notice that NOT all counters are available on various systems.
84 //! Standard_Size(-1) means invalid (unavailable) value.
85 Standard_EXPORT Standard_Size ValueMiB (const OSD_MemInfo::Counter theCounter) const;
89 //! Return the string representation for all available counter.
90 Standard_EXPORT static TCollection_AsciiString PrintInfo();
94 Standard_Size myCounters[MemCounter_NB]; //!< Counters' values, in bytes
98 #endif // _OSD_MemInfo_H__