Does Keep Alive Improve Performance Of Garbage Collector ?

I’ve just read this for what I’ve been thinking about for quite some time, … but now it just came to my mind if I make stuff KeepAlive(); would performance be better?

reading that I learned this would be worst performance:

	void Start(){
		for (int i=0; i<1000; i++) {
			SomeFunction();
		}
	}
	void SomeFunction(){
		float variable = 4;
		// some code to use variable
		if (variable == 4){
			variable = 5;
		}
	}

but I have some pools where my characters MUST NOT die (be destroyed or else I get errors) around 20 - 40 variables per character and if I make variables:

System.GC.KeepAlive(variable);

for every variable that that character posses would it make performance on Garbage collector faster?

like less object variables to verify, …

and how would I free them back after loading new scene?

as in new scene I’ll most certainly need to loose all GO with witch are scripts with keep alive

A value typed variable, like the float in your example, will be deleted as soon as SomeFunction leaves scope. Local value type variables are created in the Stack, not in the Heap. As soon as a function returns, all local variables in its Stack are freed. The GC has nothing to do there.

Only if you are creating reference type objects they will affected by the GC.