ScrollRect.LateUpdate() spike in profiler allocating GC upto 2.4MB
<p>Following up <a href="https://stackoverflow.com/questions/38959670/optimization-to-avoid-jitters-on-cardboard-app-when-moving-camera-with-head-on-a">my previous question</a> regarding Profiler spikes. I have just figured out that if I enable deep profile option in Unity3D I can see <code>GetComponent()</code> call under <code>ScrollRect.LateUpdate()</code> is taking up to 2.4 MB memory for garbage collection for only 5 <code>Scroll Rect</code> components. As it is obvious from the following snapshot that Unity is calling <code>Component.GetComponent()</code> for 4046 times in <code>LateUpdate()</code> method which causes performance issue. My application is UI intense, but 2.4MB for GC is not accepable at all. </p>

<p><img src="https://i.stack.imgur.com/Ax2VY.png" alt="enter image description here"></p>

<p>Usually It is recommended not to use <code>GetComponent()</code> in any of update methods but Unity's own implementation is breaking the convention. Which limits the number of UI items I can have in one scene to avoid the performance issues.</p>

<p>Note this profiling data is only from the frame when I activate a menu object.</p>

<p>Is there any workaround to reduce/save 2.4MB of memory?</p>