- Home /
Question by
UnplugtheDamnThing · Jun 12, 2015 at 02:30 PM ·
gameobjectmemory managementmemory usage
How is memory handled when using multiple variables to refer to Objects in the scene
I was wondering how much memory is wasted when multiple variables refer to the same GameObject. Does each reference to the GameObject now increase total memory used by the amount the original GameObject took up? If I did the following :
public GameObject myObject;
GameObject[] myObjectInArray = new GameObject[1];
List<GameObject> myObjectInList = new List<GameObject>();
void Start()
{
myObjectInArray[0] = myObject;
myObjectInList.Add(myObject);
}
would this be a massive waste of memory where myObject, myObjectInArray[0] and myObjectInList[0] all hold every bit of information about the GameObject in question OR will they all simply hold a reference to the GameObject in the scene and thus not use all that much memory?
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613200912im_/https://answers.unity.com/themes/thub/images/avi.jpg)