Im using this stuff that I found in the docs, I dont know what it does but its supposed to help. Is it likely to cause harm instead?
DontDestroyOnLoad(this);
function Start () {
useGUILayout = false;
var tmp = new System.Object[1024];
// make allocations in smaller blocks to avoid them to be treated in a special way, which is designed for large blocks
for (var i : int = 0; i < 1024; i++)
tmp[i] = new byte[1024];
// release reference
tmp = null;
iPhoneKeyboard.autorotateToPortrait = false;
iPhoneKeyboard.autorotateToPortraitUpsideDown = false;
iPhoneKeyboard.autorotateToLandscapeRight = false;
}
System.GC.Collect just forces a garbage collection to happen immediately instead of waiting for memory to run out. This is really only used to make the CPU spike associated with the collection happen at a predictable place rather than in mid-game. It shouldn’t have any effect on the amount of memory allocated.
Likewise, the allocation of all those blocks of bytes is simply to expand the size of the heap at a predictable point in the game to avoid pregnant pauses.
At what point does the game crash? Does it happen after a certain amount of time or does the user have to do something first? Does the editor freeze or does the whole Unity app quit?