-
Notifications
You must be signed in to change notification settings - Fork 1
/
MemoryInfo.cpp
129 lines (73 loc) · 2.3 KB
/
MemoryInfo.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
// MemoryInfo.cpp: implementation of the CMemoryInfo class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "CPUBench2004.h"
#include "MemoryInfo.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CMemoryInfo::CMemoryInfo()
{
GlobalMemoryStatus(&m_MemStatus);
GetSystemInfo(&m_SysInfo);
}
CString CMemoryInfo::GetRAMSize() {
CString str;
str.Format("%d MByte",m_MemStatus.dwTotalPhys/(1024*1024)+1);
return str;
}
CString CMemoryInfo::GetRAMAvailable() {
CString str;
str.Format("%d MB",m_MemStatus.dwAvailPhys/(1024*1024));
return str;
}
int CMemoryInfo::GetRAMAvailablePercent() {
return (int)(((float)m_MemStatus.dwAvailPhys/(float)m_MemStatus.dwTotalPhys)*100);
}
int CMemoryInfo::GetMemLoadPercent() {
return m_MemStatus.dwMemoryLoad;
}
CString CMemoryInfo::GetVirtualSize() {
CString str;
str.Format("%d MByte",m_MemStatus.dwTotalVirtual/(1024*1024));
return str;
}
CString CMemoryInfo::GetVirtualAvailable() {
CString str;
str.Format("%d MByte",m_MemStatus.dwAvailVirtual/(1024*1024));
return str;
}
int CMemoryInfo::GetVirtualAvailablePercent(){
return (int)(((float)m_MemStatus.dwAvailVirtual/(float)m_MemStatus.dwTotalVirtual)*100);
}
CString CMemoryInfo::GetPageFileAvailable() {
CString str;
str.Format("%d MByte",m_MemStatus.dwAvailPageFile/(1024*1024));
return str;
}
CString CMemoryInfo::GetPageFileSize() {
CString str;
str.Format("%d MByte",m_MemStatus.dwTotalPageFile/(1024*1024));
return str;
}
int CMemoryInfo::GetPageFileAvailablePercent() {
return (int)(((float)m_MemStatus.dwAvailPageFile/(float)m_MemStatus.dwTotalPageFile)*100);
}
CString CMemoryInfo::GetMinAppAddress() {
return (int)m_SysInfo.lpMinimumApplicationAddress;
}
CString CMemoryInfo::GetMaxAppAddress() {
return (int)m_SysInfo.lpMaximumApplicationAddress;
}
CString CMemoryInfo::GetAllocationGranularity() {
return m_SysInfo.dwAllocationGranularity;
}
CMemoryInfo::~CMemoryInfo()
{
}