Linked Questions
15 questions linked to/from How big is an object reference in .NET?
14
votes
3
answers
4k
views
How much memory does a C# reference consume? [duplicate]
How much memory does a C# reference consume?
Does References consumes memory as much as the object itself?
-1
votes
1
answer
1k
views
Allocate memory to variable in c# [duplicate]
I have the following lines of code:
SomeClass a;
SomeClass b = new SomeClass();
SomeClass c = new SomeClass()
{
Foo="sss",
Bar="dddd"
};
Whats the size (in memory) of the class instances a, ...
0
votes
0
answers
79
views
Is a reference write always atomic? [duplicate]
According to this question: How big is an object reference in .NET? , .Net references are 32bit on x86 and 64bit on x64. When a 64bit reference is written is it done atomically or as 2 separate 32bit ...
1
vote
0
answers
49
views
What size is the pointer to the class? [duplicate]
public class PersonClass
{
public string Name;
public string Name1;
public string Name2;
public byte Age;
public byte Age1;
public byte Age2;
}
I ...
21
votes
6
answers
12k
views
sizeof() equivalent for reference types?
I'm looking for a way to get the size of an instance of a reference type. sizeof is only for value types. Is this possible?
6
votes
5
answers
5k
views
c# reference variable mem allocation
Does anyone know how much memory is taken up when you create a reference type variable?
String s = "123";
How much memory would 's' take up as a reference, not the data pointing to it?
10
votes
1
answer
6k
views
How many bytes of memory does each type in .NET consume (32-bit environment)? [closed]
How much memory in bytes do types like int, bool, float, double, decimal, object, and string use when added as a field to an instance of a class?
12
votes
4
answers
3k
views
Is there any C# analogue of C++11 emplace/emplace_back functions?
Starting in C++11, one can write something like
#include <vector>
#include <string>
struct S
{
S(int x, const std::string& s)
: x(x)
, s(s)
{
}
int ...
4
votes
2
answers
2k
views
Best way for memory to pass method parameters
I am experiencing some memory performance issues with my code and I am not sure which is the best way to pass parameters to my methods. I will give a short example about this.
I have for instance ...
0
votes
1
answer
542
views
Memory performance IList<T> vs List<T> property
I'm writing a class where I have a collection of objects of class A and I'm writing a function similar to Dictionary<TKey,TValue>.TryGetValue(TKey,TValue)
It looks pretty similar to this:
...
-1
votes
2
answers
642
views
Initializing ListView, why can't I do this?
As an old C++ programmer I am struggling with some C# issues. I want to reduce the redundancy in setting up a ListView. So I tried the code below. I get a null reference error, but I do not ...
0
votes
2
answers
216
views
Tagged pointer for .NET (C#) object reference
I learned that an object reference of .NET (C#) is just a pointer.
My questions are:
Is the address of the object aligned depending on the CPU architecture and/or the object's size?
If the above is ...
1
vote
1
answer
376
views
How is memory allocated for a C# class?
I have a class like this,
public class Cube
{
private int[,] data;
public Cube()
{
data[,] = new int[3,3];
data[0,0] = 1;
data[1,0] = 2;
// etc
}
...
0
votes
1
answer
74
views
Is there a difference in memory allocation when declaring a new array in a class? [closed]
Is there a difference in memory usage / allocation for the class myObjectA and myObjectB?
For example if I don't want to add a velocity to every object of that class will is use more memory having ...
-3
votes
1
answer
67
views
What is an Object which is not an instance and vice versa? [duplicate]
I am trying to understand the difference between the object and instance and in some forums it is mentioned as same and in other it is mentioned as different.
Q.1 If we instantiate 4 different ...