Click here to Skip to main content
15,892,809 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
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.
C#
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;

}


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
Posted
Updated 27-Dec-10 5:25am
v2

You can also have a look here[^] to measure memory usage.
 
Share this answer
 
You can use the tool memprofilter[^]. I hope response to your question.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900