0

I want to obtain memory usage of a C++ project in Microsoft Visual Sutio 2019 on Win 7 64 bit. I followed the post How to determine CPU and memory consumption from inside a process?

By using this code inside my main function:

#include "windows.h"
#include "psapi.h"

int main()
{
    PROCESS_MEMORY_COUNTERS_EX pmc;
    GetProcessMemoryInfo(GetCurrentProcess(), (PROCESS_MEMORY_COUNTERS*)&pmc, sizeof(pmc));
    SIZE_T virtualMemUsedByMe = pmc.PrivateUsage;
    // My function here
}

And when I change my function parameters to increase workloads, the result of virtualMemUsedByMe is always 2516k.

What is wrong here with me?

Hatran
  • 1
  • Memory isn't equivalent to CPU usage. Maybe your workload increased but the memory used remains the same. – Aplet123 Mar 28 '20 at 16:14
  • @Aplet123 But in Resource Monitor I can see the memory usage is increased when I increased workloads. Do you have any other ideas? – Hatran Mar 29 '20 at 01:17
  • Do you really call your function *after* measuring memory usage? – numzero Mar 29 '20 at 01:24

0 Answers0