Windows is an on-demand virtual memory operating system. Allocation of memory by the new operator assigns virtual memory. You will not start using physical memory, RAM, until you gain access to the memory. What you did not do.
You can force the allocation of RAM by touching each 4096th byte, it is better to record or it will be optimized:
size_t size = 1024 * 1024; ptr[i] = new char[size]; for (size_t j = 0; j < size; j += 4096) ptr[i][j] = 0;
But this is a completely pointless thing, it just slows down your program. And in fact, it does not test anything, the process cannot end from RAM to Windows. Put the task manager in programmer mode, add a column for the size of Commit. This is a real number.
source share