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 new float[2] in the class?
Also whats the memory usage of "itemA" if I create a new "myObjectA" object but I don't add a new ItemA aka its at null, does it still use memory?
and how much memory would it use if I create an new "ItemA" (myItem) and then create a new "myObjectA" (myObject), myObject.item = myItem;
I assume it' a pointer pointing at (myItem)as reference but how much memory would that pointer use? and is there a difference between leaving it at null?
Example C#
public class itemA
{
Color color = Color.FromArgb(255,0,0); //3byte
}
itemA myItem = new itemA();
public class myObjectA
{
float[] pos; // ?byte
float[] velocity; // ?byte
itemA item; // ?byte
}
myObjectA myObject0 = new myObjectA();
public class myObjectB
{
float[] pos = new float[2]; // 8byte
float[] velocity = new float[2];// 8byte
itemA item; //?byte
}
myObjectB myObject1 = new myObjectB();