获取应用程序特定部分的内存使用情况 [英] Get the memory usage of specific part of application

查看:95
本文介绍了获取应用程序特定部分的内存使用情况的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果有一种简单的方法来衡量应用程序的某个部分正在消耗多少内存,那么任何人都有任何想法吗?

例如,我有一个加载文本文件的应用程序,处理这些文件并接受另一个文件一。我需要测量单个文件处理所需的内存量。

我知道我可以停止GC并获取内存快照,但这会影响性能,没有人建议为此目的这样做。 />


还有其他任何想法吗?



顺便说一下 - 我对任何分析工具都不感兴趣需要将这个内存使用记录到数据库中。

并且到处都有很多这样的和平。



谢谢!



我尝试了什么:



做了一些googlig。

在MSDN上阅读几篇文章

Anyone have any ideas if there is a simple way to measure how much memory a certain part of application is consuming?
For example I got an application that load text files, processes these and takes another one. I need to measure how much memory the single file processing took.
I know I could stop the GC and take the memory snapshots, but this would affect performance and nobody recommends doing that for such purpose.

Any other ideas for this?

by the way- I am not interested in any profiling tool since I need to log this memory usage into db.
And there are many such peaces running everywhere.

thanks!

What I have tried:

did some googlig.
read several articles on MSDN

推荐答案

您是否尝试过使用以下方法?



Have you tried using the below method ?

GC.GetTotalMemory(true)





这可以在方法的开头/结尾使用并获得差异。



问候

Dominic



This you can use at start / end of the method and get the difference.

Regards
Dominic


这篇关于获取应用程序特定部分的内存使用情况的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆