预测进程的内存使用情况
我正在开发一个使用并行计算的应用程序。要知道可以并行运行多少个任务,我需要能够预测每个任务将占用的内存量。
我(大约)知道每个任务将使用每种类型的多少数据。
我如何预测内存使用情况?使用流程指标进行运筹学?总结很多sizeof()?
我使用 Windows 7 x64 版本。每个任务都在单独的进程中运行。
I work on an application that uses parallel computing. To know how many tasks I can run in parallel, I need to be able to predict the amount of memory each task will occupy.
I know (approximately) how much data of each type each task will use.
How do I go about predicting memory usage? Perform operations research using process metrics? Sum up many sizeof()s?
I work on Windows 7, x64 edition. Each task runs in a separate process.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
因此,您实际上要做的是找到每个任务大约占用的最大内存量。
有一个 .net 函数可以做到这一点。它称为
Process::PeakWorkingSet64
:在进程退出之前添加此代码,将获得您想要的信息(以千字节为单位)。
So what you are actually trying to do is to find the maximal amount of memory each task will take, approximately.
There is a .net function that does exactly that. It's called
Process::PeakWorkingSet64
:Add this code before your process exits and will will get the info you want, in Kbytes.
在高峰运行时间,调用 GetProcessMemoryInfo 对于任务之一并获取特定任务(进程)的内存使用情况。您可能还想通过在不同时间对不同任务调用此函数来获取此数据的样本,以获得更精确的平均值。
At its peak running time, call GetProcessMemoryInfo for one of the task and get the memory usage of particular task(process). You may also want to get a sampling of this data by calling this function on different tasks at different times to get more precise average.