Get information about CPU memory usage

部署运行你感兴趣的模型镜像
#include <iostream>
#include <iomanip>
#pragma comment (lib, "psapi.lib") // Add 'psapi.lib' to your linker options 

#include <windows.h>
#include <psapi.h> 

using namespace std; 

int main()
{
  // Open current process
  HANDLE hProcess = ::OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, ::GetCurrentProcessId());
  if(hProcess)
  {
    PROCESS_MEMORY_COUNTERS ProcessMemoryCounters; 

    memset(&ProcessMemoryCounters, 0, sizeof(ProcessMemoryCounters)); 

    // Set size of structure
    ProcessMemoryCounters.cb = sizeof(ProcessMemoryCounters); 

    // Get memory usage
    if(::GetProcessMemoryInfo(hProcess,
                              &ProcessMemoryCounters,
                              sizeof(ProcessMemoryCounters)) == TRUE)
    {
      std::cout << std::setfill('0') << std::hex
                << "PageFaultCount: 0x" << std::setw(8)
                << ProcessMemoryCounters.PageFaultCount << std::endl
                << "PeakWorkingSetSize: 0x" << std::setw(8)
                << ProcessMemoryCounters.PeakWorkingSetSize << std::endl
                << "WorkingSetSize: 0x" << std::setw(8)
                << ProcessMemoryCounters.WorkingSetSize << std::endl
                << "QuotaPeakPagedPoolUsage: 0x" << std::setw(8)
                << ProcessMemoryCounters.QuotaPeakPagedPoolUsage << std::endl
                << "QuotaPagedPoolUsage: 0x" << std::setw(8)
                << ProcessMemoryCounters.QuotaPagedPoolUsage << std::endl
                << "QuotaPeakNonPagedPoolUsage: 0x" << std::setw(8)
                << ProcessMemoryCounters.QuotaPeakNonPagedPoolUsage << std::endl
                << "QuotaNonPagedPoolUsage: 0x" << std::setw(8)
                << ProcessMemoryCounters.QuotaNonPagedPoolUsage << std::endl
                << "PagefileUsage: 0x" << std::setw(8)
                << ProcessMemoryCounters.PagefileUsage << std::endl
                << "PeakPagefileUsage: 0x" << std::setw(8)
                << ProcessMemoryCounters.PeakPagefileUsage <<std::endl;
    }
    else
      std::cout << "Could not get memory usage (Error: "
                << ::GetLastError() << ")" << std::endl; 

    // Close process
    ::CloseHandle(hProcess);
  }
  else
    std::cout << "Could not open process (Error "
              << ::GetLastError() << ")" << std::endl; 

  return 0;
} 

 

#pragma   comment(lib,"Ws2_32.lib")表示链接Ws2_32.lib这个库。和在工程设置里写上链入Ws2_32.lib的效果一样,不过这种方法写的程序别人在使用你的代码的时候就不用再设置工程settings了。

您可能感兴趣的与本文相关的镜像

我是一个嵌入式新人,导师让我使用串口板进行调试(实际完全不知道怎么做),我连接登录进自研系统,help给出。nvt@na51089: help ? - alias for 'help' base - print or set address offset bdinfo - print Board Info structure blkcache - block cache diagnostics and control bootm - boot application image from memory bootp - boot image via network using BOOTP/TFTP protocol chpart - change active partition cmp - memory compare cp - memory copy crc32 - checksum calculation dhcp - boot image via network using DHCP/TFTP protocol env - environment handling commands exit - exit script false - do nothing, unsuccessfully fatinfo - print information about filesystem fatload - load binary file from a dos filesystem fatls - list files in a directory (default /) fatmkdir - create a directory fatrm - delete a file fatsize - determine a file's size fatwrite - write file into a dos filesystem fdt - flattened device tree utility commands go - start application at address 'addr' gpio - query and control gpio pins help - print command description/usage httpd - httpd - start www server for firmware recovery loop - infinite loop on address range md - memory display md5sum - compute MD5 message digest mm - memory modify (auto-incrementing address) mmc - MMC sub system mmcinfo - display MMC info mtdparts - define flash/nand partitions mw - memory write (fill) nand - NAND sub-system nboot - boot from NAND device nm - memory modify (constant address) nvt_boot - To do nvt platform boot init. nvt_cpu_freq- change cpu freq nvt_encrypt- To encrypt via key manager sample nvt_get_cpu_freq- get cpu freq nvt_get_ddr_freq- get ddr freq/type nvt_jtag_disable- jtag disable nvt_key_set_engine_right- To read key set X nvt_read_key_set- To read key set X nvt_read_lock- To let key set X un-readable nvt_rtos_disable- To disable uboot boot rtos nvt_secure_en- secure enable related API nvt_uart_disable- To disable uart print nvt_write_key- To write key via OTP sample ping - send ICMP ECHO_REQUEST to network host printenv - print environment variables pwm - nvt pwm operation reset - Perform RESET of the CPU setenv - set environment variables showvar - print local hushshell variables test - minimal test like /bin/sh tftpboot - boot image via network using TFTP protocol true - do nothing, successfully ubi - ubi commands version - print monitor, compiler and linker version
最新发布
09-19
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值