GetProcessMemoryInfo
来源:互联网 发布:淘宝总销售额查询 编辑:程序博客网 时间:2024/05/16 19:39
GetProcessMemoryInfo
#include <iostream>#include <windows.h>#include <psapi.h>#pragma comment(lib,"psapi.lib")using namespace std;void showMemoryInfo(void){ HANDLE handle=GetCurrentProcess(); PROCESS_MEMORY_COUNTERS pmc; GetProcessMemoryInfo(handle,&pmc,sizeof(pmc)); cout<<"内存使用:"<<pmc.WorkingSetSize/1024 <<"/"<<pmc.PeakWorkingSetSize/1024<<" + "<<pmc.PagefileUsage/1024 <<"/"<<pmc.PeakPagefileUsage/1024 <<""<<endl;}int _main(int argc,char* argv){ showMemoryInfo(); cout<<"回收所有可回收的内存"<<endl; EmptyWorkingSet(GetCurrentProcess()); showMemoryInfo(); cout<<"开始动态分配内存"<<endl; char* buf[5]; for(int i=0;i<sizeof(buf)/sizeof(char*);i++) { buf[i]=new char[102400]; showMemoryInfo(); } cout<<"开始释放内存"<<endl; for(int i=0;i<sizeof(buf)/sizeof(char*);i++) { delete buf[i]; buf[i]=NULL; showMemoryInfo(); } cout<<"回收所有可回收的内存"<<endl; EmptyWorkingSet(GetCurrentProcess()); showMemoryInfo(); return 0;}#include <stdio.h>#include <windows.h>#include <TlHelp32.h>int main(int argc,char **argv){ HANDLE handle; handle = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0); if(handle == INVALID_HANDLE_VALUE) { printf("Gain snapshot falid\n"); return -1; } PROCESSENTRY32 pe; pe.dwSize = sizeof(pe); BOOL flag = Process32First(handle,&pe); while(flag){ char buff[MAX_PATH]; sprintf(buff,"%i---------%s",pe.th32ProcessID,pe.szExeFile); printf("%s\n",buff); flag = Process32Next(handle,&pe); } return 0;}
0 0
- GetProcessMemoryInfo
- GetProcessMemoryInfo函数
- GetProcessMemoryInfo function
- GetProcessMemoryInfo函数
- 用GetProcessMemoryInfo 函数 获取内存
- Windows API一日一练(91)GetProcessMemoryInfo函数
- cocos2d-x获取程序当前内存使用量 GetProcessMemoryInfo 函数
- 获取对应进程的内存使用情况(GetProcessMemoryInfo)
- IntelliJ 使用笔记
- vijosP1282 佳佳的魔法照片
- 报表开发导出各种格式文件的API
- 高效定时器的实现方式
- Andoid自动判断输入是电话,网址或者Email的方法----Linkify的应用!
- GetProcessMemoryInfo
- beanUtils 使用
- pkg-config的使用
- Android ListView优化篇
- 福兮祸兮?
- 代理模式-延迟加载场景
- 求斐波那契数列前20项
- C#调用SQL中的存储过程中有output参数
- VIJOS P1752潜伏者