类的内存分配 [英] Memory allocation of a class

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

问题描述



只是想让我的基础知识正确.如果我声明一个带有字符串变量,一个int和一个数据表的类,并实例化它将消耗多少内存.

Hi,

Just trying to get my basics right. If I declare a class with a string variable, an int, and a datatable and i instantiate it how much memory it will consume.

class A
{
private int i;
private string s

public int ii
{
   get; set;
}
public string ss
{
   get;set;
}
}

class B
{
    A obj = new A();
    A.ii = 23;

}



在这里,我想知道实例化类(A obj=new A();)时将分配多少存储空间.现在,当A.ii=23时将为该类分配多少内存.可以容纳一些内存的未分配的字符串变量有什么作用(我不记得字符串是否有最大字节限制).

提前谢谢.

afsal



Here I would like to know how much memory space will be allotted when I instantiate the class( A obj=new A(); ). Now how much memory will be allotted to the class when A.ii=23. What is the effect of an unassigned string variable which can hold some memory ( I don''t remember if there is any maximum byte limit for string).

Thanks in advance.

afsal

推荐答案

您也可以看看这里 [ ^ ]来衡量内存使用情况.
You can also have a look here[^] to measure memory usage.


您可以使用工具 memprofilter [
You can use the tool memprofilter[^]. I hope response to your question.


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

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