unity puts all the game scripts to memory

Hi everyone!

I found an interesting aspect, unity puts all the game scripts to memory! This is a fail.
My game has about 50 scenes, all of them takes just about 25 mb. I write under iOS with c# and memory is very important for me. I know about option “Scripping Level” if it set to “Scrip ByteCode” it helps but not much. May be someone know a black magic to resolve this problem?

“Scripts” don’t need much memory. The classes have to be available for the mono environment. Since you can attach components dynamically all classes have to be available. Unity only loads your assembly into memory which is usually way below 1MB. That’s almost nothing. Only script instances might need more memory, but those only need memory when they are created / loaded in a scene.

Check the editor log after you created a build, it usually tells you quite detailed howbig your scripts really are.

The Unity player (the engine itself) is usually way larger than your scripts. Your scripts certainly aren’t the bottleneck.

Try using the profiler (when you have Unity pro) to track down what needs the most memory.

Build series of AssetBundle and load them as and when needed into your scene.