MCPcopy Create free account
hub / github.com/Kitware/CMake / QueryWindowsMemory

Method QueryWindowsMemory

Source/kwsys/SystemInformation.cxx:4109–4143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4107}
4108
4109bool SystemInformationImplementation::QueryWindowsMemory()
4110{
4111#if defined(_WIN32)
4112# if defined(_MSC_VER) && _MSC_VER < 1300
4113 MEMORYSTATUS ms;
4114 unsigned long tv, tp, av, ap;
4115 ms.dwLength = sizeof(ms);
4116 GlobalMemoryStatus(&ms);
4117# define MEM_VAL(value) dw##value
4118# else
4119 MEMORYSTATUSEX ms;
4120 DWORDLONG tv, tp, av, ap;
4121 ms.dwLength = sizeof(ms);
4122 if (0 == GlobalMemoryStatusEx(&ms)) {
4123 return 0;
4124 }
4125# define MEM_VAL(value) ull##value
4126# endif
4127 tv = ms.MEM_VAL(TotalPageFile);
4128 tp = ms.MEM_VAL(TotalPhys);
4129 av = ms.MEM_VAL(AvailPageFile);
4130 ap = ms.MEM_VAL(AvailPhys);
4131 this->TotalVirtualMemory = tv >> 10 >> 10;
4132 this->TotalPhysicalMemory = tp >> 10 >> 10;
4133 this->AvailableVirtualMemory = av >> 10 >> 10;
4134 this->AvailablePhysicalMemory = ap >> 10 >> 10;
4135
4136 // The virtual WinAPI memory contains both physical memory and page file.
4137 this->TotalVirtualMemory -= this->TotalPhysicalMemory;
4138 this->AvailableVirtualMemory -= this->AvailablePhysicalMemory;
4139 return true;
4140#else
4141 return false;
4142#endif
4143}
4144
4145bool SystemInformationImplementation::QueryLinuxMemory()
4146{

Callers 1

RunMemoryCheckMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected