November 2019
Intermediate to advanced
404 pages
12h 9m
English
Several instructions within the Unity API result in heap memory allocations, which we should be aware of. This essentially includes everything that returns an array of data. For example, the following methods allocate memory on the heap:
GetComponents<T>(); // (T[])Mesh.vertices; // (Vector3[])Camera.allCameras; // (Camera[])
Each and every time we call a Unity API method that returns an array will cause a whole new version of that data to be allocated. Such methods should be avoided whenever possible or at the very least called once and cached so that we don't cause memory allocations more often than necessary.
There are other Unity API calls where we provide an array of elements to a method, and it writes the necessary ...
Read now
Unlock full access