Optimize (Garbage Collection, Memory usage)

I have some questions about Optimization.

I've heard that garbage collection will be executed automatically when developing for Windows in Unity. Is there any way to manually collect garbage in order to not affect game performance ?

Second, is there any performance or memory usage differences between those 2 code scripts ?

Code Script 1:

#pragma strict

private static var constNumber : float = 0.5f ;

function Update()
{
    var fltCount: float = 0.7 + time.deltaTime
    fltCount -= constNumber
}

Code Script 2

#pragma strict

private static var constNumber : float = 0.5f ;
private var fltcount: float ;

function Update()
{
    fltCount = 0.7 + time.deltaTime
    fltCount -= constNumber
    //could be written in one line but that's not my essential question
}

Third question: When using the yield instructions, will there be a other CPU core used ? (If available)

1. You can probably use GC.Collect to manually tell garbage collector to clean out old data, although I haven't done manually so with Unity/Mono.

You also might want to look for pointers about when to use it.

2. Negligible difference, if any at all. I wouldn't worry. You can probably remove one arithmetic operation if you do:

fltCount = (0.7f - constNumber) + time.deltaTime; 

Because the first two values on right side are constant and can be computed compile time (Parenthesis added for clarity).

The compiler should output:

fltCount = 0.2f + time.deltaTime; 

EDIT: Actually, your constNumber is a static, and the compiler won't be able to make this assumption!

3. Yield instructions don't run threaded, so no. You must create your own threads for concurrent/parallel execution. When using threads to utilize several cores you must take action to avoid state corruption, deadlocks, and not call most of the Unity functions as they are generally not thread safe.