Memory usage of class instance in c# [duplicate]

筅森魡賤 提交于 2019-12-10 18:43:37

问题


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)


回答1:


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.




回答2:


You can check this one - Find size of object instance in bytes in c#



来源:https://stackoverflow.com/questions/4752439/memory-usage-of-class-instance-in-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!