Created
July 3, 2019 12:15
-
-
Save katahiromz/b4f73c25a92f60b1b40b544a3b0474e1 to your computer and use it in GitHub Desktop.
MemCheck1.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <windows.h> | |
#include <vector> | |
#include <iostream> | |
int main(void) | |
{ | |
MEMORYSTATUS ms1, ms2; | |
{ | |
std::vector<DWORDLONG> vec(0xFFFFFF, 1); | |
for (int i = 0; i < 0xFFFFFF; i += 0x100) | |
vec[i] = char(i); | |
ms1.dwLength = sizeof(ms1); | |
GlobalMemoryStatus(&ms1); | |
} | |
#define POUT(x) std::cout << #x ": " << x << std::endl; | |
ms2.dwLength = sizeof(ms2); | |
GlobalMemoryStatus(&ms2); | |
POUT(ms1.dwMemoryLoad - ms2.dwMemoryLoad); | |
POUT(ms1.dwTotalPhys - ms2.dwTotalPhys); | |
POUT(ms1.dwAvailPhys - ms2.dwAvailPhys); | |
POUT(ms1.dwTotalPageFile - ms2.dwTotalPageFile); | |
POUT(ms1.dwAvailPageFile - ms2.dwAvailPageFile); | |
POUT(ms1.dwTotalVirtual - ms2.dwTotalVirtual); | |
POUT(ms1.dwAvailVirtual - ms2.dwAvailVirtual); | |
return 0; | |
} | |
// OUTPUT: | |
// C:\Users\katahiromz\Desktop\MemCheck>MemCheck1 | |
// ms1.dwMemoryLoad - ms2.dwMemoryLoad: 3 | |
// ms1.dwTotalPhys - ms2.dwTotalPhys: 0 | |
// ms1.dwAvailPhys - ms2.dwAvailPhys: 4170416128 | |
// ms1.dwTotalPageFile - ms2.dwTotalPageFile: 0 | |
// ms1.dwAvailPageFile - ms2.dwAvailPageFile: 0 | |
// ms1.dwTotalVirtual - ms2.dwTotalVirtual: 0 | |
// ms1.dwAvailVirtual - ms2.dwAvailVirtual: 4160749568 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment