Any memory overhead difference between....

if I have a GameManager singleton, with some variables in it, is there a difference in memory overhead between these two?

static var score : int;

and

var score : int;

and then referencing like…

GameManager.score = 100;

and

GameManager.instance.score = 100;

?

I used to just make everything a static var, but I am wondering if there is more memory overhead fro that?

statics require the same memory. the difference is that this memory can not be pushed out with the object, it is perma locked and accessable as statics need to be accessable at any time not only when a instance of said class in memory

I dont think there is a difference in perfomance and while it might not be an issue in scripting Singletons would in most cases(all if you ask me) be preferable. The singleton classes are polymorphic and can use interfaces. And in my case I have all my other managers in a singleton and call them like this GameManager.Instance.AudioManager.SetGameVolume(0.5f);

There might be reasons to use static classes, but I would recommend the singleton pattern.

Static variable is stored once (it’s like “global”). So in your case, it’s 4 bytes of memory.

A non-static variable is a variable for each instance. So in your case, it’s 4 bytes per each instance. But since there’s only one instance, then the sum is the same.

Awesome, ok, thats exactly what I was looking for… Thanks everyone!