是否有可能来跟踪C#应用程序的内存使用情况,而无需使用分析器? [英] Is it possible to track memory usage in a C# application without using a profiler?

查看:224
本文介绍了是否有可能来跟踪C#应用程序的内存使用情况,而无需使用分析器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写一个简单的应用程序,它可以跟踪其当前的内存使用量,创建的对象的数量等在C ++中我通常会覆盖新的运营商,但由于显而易见的原因,我不能在C#这样做。有没有办法做到这一点,而无需使用分析器?

I'd like to write a simple application which keeps track of its current memory usage, number of created objects etc. In C++ I'd normally override the new operator, but for obvious reasons I can't do this in C#. Is there any way to do this without using a profiler?

推荐答案

您可能要开始与垃圾收集器。 MSDN有上市这里,可以告诉你如何某些成员做了几件事情,就像得到了内存认为分配,多少次GC已收集的总量。什么比这更先进,比如让你加载的程序集的对象的数量,你必须可能使用一个分析器或写自己的东西。

You might want to start with the Garbage Collector. MSDN has some members listed here that can show you how to do a few things, like get the total amount of memory it thinks is allocated, how many times the GC has collected. Anything more advanced than that, like getting a count of objects of your loaded assembly and you'll have to probably use a profiler or write something yourself.

这篇关于是否有可能来跟踪C#应用程序的内存使用情况,而无需使用分析器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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