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