[HELP] Unity crashes: OutOfMemoryException

Since adding the code of this lecture the editor freezes for a while and then crashes. Sometimes it does not crash, but it wont run the game. It gives me this error message:

OutOfMemoryException: Out of memory
System.Array.Resize[Waypoint] (.Waypoint[]& array, Int32 length, Int32 newSize) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Array.cs:1929)
System.Array.Resize[Waypoint] (.Waypoint[]& array, Int32 newSize) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Array.cs:1913)
System.Collections.Generic.List1[Waypoint].set_Capacity (Int32 value) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/List.cs:622) System.Collections.Generic.List1[Waypoint].GrowIfNeeded (Int32 newCount) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/List.cs:100)
System.Collections.Generic.List`1[Waypoint].Add (.Waypoint item) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/List.cs:91)
Pathfinder.CreatePath () (at Assets/Scripts/Pathfinder.cs:35)
Pathfinder.Start () (at Assets/Scripts/Pathfinder.cs:25)

I don’t know what is causing this, but it seems to be something with the arrays. The code is too complicated for my to figure out on my own.

Privacy & Terms