C++

Asked • 09/29/19

How to determine CPU and memory consumption from inside a process?

I once had the task of determining the following performance parameters from inside a running application: - Total virtual memory available - Virtual memory currently used - Virtual memory currently used by my process<hr> - Total RAM available - RAM currently used - RAM currently used by my process<hr> - % CPU currently used - % CPU currently used by my process The code had to run on Windows and Linux. Even though this seems to be a standard task, finding the necessary information in the manuals (WIN32 API, GNU docs) as well as on the Internet took me several days, because there's so much incomplete/incorrect/outdated information on this topic to be found out there. In order to save others from going through the same trouble, I thought it would be a good idea to collect all the scattered information plus what I found by trial and error here in one place.

1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.