如何從進程內部肯定CPU和內存消耗? - 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: 我曾經負責從運行的應用程序內部肯定如下性能參數的任務: app

  • Total virtual memory available 可用虛擬內存總量
  • Virtual memory currently used 當前使用的虛擬內存
  • Virtual memory currently used by my process 個人進程當前使用的虛擬內存
  • Total RAM available 總可用RAM
  • RAM currently used 當前使用的RAM
  • RAM currently used by my process 個人進程當前使用的RAM
  • % CPU currently used 當前使用的CPU百分比
  • % CPU currently used by my process 個人進程當前使用的CPU百分比

The code had to run on Windows and Linux. 該代碼必須在Windows和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. 儘管這彷佛是一項標準任務,但在手冊(WIN32 API,GNU文檔)以及Internet上找到必要的信息仍是花了我幾天的時間,由於關於該主題的信息太多,不完整/不正確/過期發如今那裏。 ide

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. 爲了使其餘人免於遭受一樣的麻煩,我認爲將全部分散的信息以及經過反覆試驗發現的信息收集到一個地方是一個好主意。 性能


解決方案:

參考一: https://stackoom.com/question/GQo/如何從進程內部肯定CPU和內存消耗
參考二: https://oldbug.net/q/GQo/How-to-determine-CPU-and-memory-consumption-from-inside-a-process
相關文章
相關標籤/搜索