问题
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