Memory usage of gameobject list

I’m not sure how Unity stores lists. Say I have a list of game objects. Is each list element a pointer to, or a copy of the game object?

I’m asking because I need to store game objects, but I think all I’ll need is the position, and I’m wondering if I’d save RAM by making a Vector3 List rather than a GameObject List. The game objects contain quite a lot of variables.

As far as I know, saving GameObjects in a list saves their reference, meaning that all you have is a pointer to the GameObject, and as far as I know two pointers (for the previous and the next atom), I’ve head somehwere that the C# list implementation is a two-way linked list. What you’re trying to do is micro optimization and I suggest you stay away from it if you want to spend your time efficiently and have readable code. Whether you save the object to the list as a Vector3 or a GameObject it woun’t change the fact that the GameObject’s components will expend system memory when active.

Also, the general rule of optimization during development is that you don’t optimize unless your game runs like crap.

If you think you’ll only every need the gameObject ‘s position, use a List of Transform, that way you’ll have access to any component you need. Hard to tell without seeing code, but if you use a List of Vector3 it will most likely be unreliable unless your gameObjects are static.

Having said that, if you’re looking to save RAM, worry about your texture and audio compression settings.