Is there an easy way to find out how much RAM (in MB) does my program use after different operations (large matrix manipulation)? I am using Windows 10.
-
That's OS specific. – Yksisarvinen Nov 20 '20 at 15:16
-
oh I am sorry, I edited the question. – mathys Nov 20 '20 at 15:17
-
I think you are looking for profiling. You should have one with [Visual Studio](https://learn.microsoft.com/en-us/visualstudio/profiling/?view=vs-2019) or can use something like Intel VTune. – Victor Gubin Nov 20 '20 at 15:33
1 Answers
The C++ standard (read e.g. n3337) don't mention RAM, so your question is operating system specific. Also, on most OSes a process runs in virtual memory, and two different processes might share some common (either virtual, or physical) memory. Read a good textbook on operating systems.
During execution, some pages might be swapped out to the swap area on your disk.
Hence, the very notion of RAM usage is approximate and changes with time. Read about thrashing and page faults and MMU.
But on Linux, you could use the /proc/
file system. Read proc(5) . Your program would access /proc/self/maps
For Windows, read the WinAPI documentation. You probably want virtual memory functions and memory management functions.
You might redefine your ::operator new
and/or use libraries like POCO. With GPGPUs and OpenCL things become even more complex. Some compilers have OpenACC extensions facilitating these.

- 223,805
- 18
- 296
- 547
-
Yeah I found out it's OS specific and edited the question. I am using Windows 10. – mathys Nov 20 '20 at 15:19