Cascades
Cascades

Reputation: 644

Why does my project/VS/Task Manager all show different memory usage? C++

Me and a small team have been working on a project that is starting to take up quite a lot of memory (for a domestic program). We are using C++20, and to my knowledge don't use anything other than smart pointers in the project.

We believe we have a memory leak somewhere, but are finding it hard to track down, and have also been very confused about the various diagnostic results we are getting from different sources. All three of the following cases were taken at exactly the same time. (Taken on Windows 10, x64)

  1. Below is our in-game profiler. We are using:
PROCESS_MEMORY_COUNTERS_EX pmc;
GetProcessMemoryInfo(GetCurrentProcess(), (PROCESS_MEMORY_COUNTERS*)&pmc, sizeof(pmc));

As you can see, it reports ~760 MB of memory usage.

enter image description here

  1. Below is what VS2019 shows us (again, at exactly the same time). ~1.5GB of "private bytes", but also only ~44KB on the heap? (Our whole application is run from a smart pointer in our main function, so it should all be in the heap, right?).

enter image description here

  1. Finally, task manager is below. This is the memory usage, and is roughly what we report in-game, but always a little bit lower.

enter image description here

In my eyes, all of these conflict somewhat, and I am utterly perplexed by the VS output. Any explanation as to what VS's output is would be greatly appreciated.

Upvotes: 2

Views: 868

Answers (1)

Mugurel
Mugurel

Reputation: 36

Check this out: msdn page

Task manager provides the working set (i.e. how much memory you use).

Visual Studio Profiler shows the total virtual memory used for storage and not shared.

Upvotes: 1

Related Questions