类实例的内存使用在c# [英] Memory usage of class instance in c#

查看:99
本文介绍了类实例的内存使用在c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

C#/。NET对象使用多少内存?




$ b b

如标题所示,我如何检查一个类实例在c#(webforms)中记忆的内存量。

解决方案

  private System.Diagnostics.PerformanceCounter ramCounter; 
ramCounter = new System.Diagnostics.PerformanceCounter(Memory,Available MBytes);

public string getAvailableRAM()
{
return ramCounter.NextValue()+Mb;
}

这些是你的处置工具:D希望有帮助。 >

Possible Duplicate:
How much memory does a C#/.NET object use?

Like the title says, how can I check how much memory a class instance takes in memory in c# (webforms)

解决方案

private System.Diagnostics.PerformanceCounter ramCounter; 
ramCounter = new System.Diagnostics.PerformanceCounter("Memory", "Available MBytes"); 

public string getAvailableRAM()
{
      return ramCounter.NextValue() + "Mb";
}

Those be the tools to your disposal :D hopefully that helps.

这篇关于类实例的内存使用在c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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