I wanted to use std::deque, but the overhead memory consumed seems too excessive. Am I doing something incorrectly?
#include "windows.h"
#include "psapi.h"
#include <iostream>
#include <vector>
#include <queue>
int main (int, char* [])
{
PROCESS_MEMORY_COUNTERS pm;
GetProcessMemoryInfo(GetCurrentProcess(), &pm, sizeof(pm));
size_t mem1 = pm.WorkingSetSize;
std::vector<int> v( 10000000 );
GetProcessMemoryInfo(GetCurrentProcess(), &pm, sizeof(pm));
size_t mem2 = pm.WorkingSetSize;
std::deque<int> q( 10000000 );
GetProcessMemoryInfo(GetCurrentProcess(), &pm, sizeof(pm));
size_t mem3 = pm.WorkingSetSize;
std::cout << mem2 - mem1 << std::endl;
std::cout << mem3 - mem2 << std::endl;
return 0;
}
Output (on a 32-bit Windows system):
40087552
72564736
Bonus question: Why is mem2 - mem1 not exactly 40000000?