![alt text][1]Hi guys,
I am currently making a game where players can select several characters in a team to fight some AI. It is a turn-based game and each character has several abilities.
As I need to make quite a number of abilities for all the different characters, I decided to create a base class called "CustomAbility" and every ability will be a subclass of "CustomAbility".
I am writing the classes in JavaScript.
In "CustomAbility", there are declarations of several "protected" variables such as
protected var level : int = 1;
protected var name : String = "Not assigned";
When I try to compile the script (hit save on the MonoDevelop then make the Unity main window the active window), I notice that the memory usage shoots up to 3.5GB++ until unity crashes.
However, when I comment out the declarations, Unity can compile successfully without going past 700MB in memory usage.
Anyone can help me understand what is going on? What happens during compile time that takes up so much memory?
EDIT: I did an experiment and after I moved every variable declared in the base class (for characters and abilities) to the subclasses (meaning now "CustomAbility" has no variables, but "Fireball", which extends "CustomAbility", has all the variables) Unity can compile in under 200MB.
This is very confusing to me, I would greatly appreciate anyone who could help me understand why this is the case. Thanks.
[1]: /storage/temp/13602-high+memory+usage+on+compile.jpg
↧