Thursday, June 2, 2011

iOS CALayers

After spending hours using Instruments to find a memory issue where real memory usage was hovering around 170-180MB on an app with many layers I finally was able to pinpoint the cause of the high memory utilization.  The issue was with the size of the CALayer frame's.  The application had about 40 large layers and each was the size of about two-thirds of the screen.  When reducing the size of the frames down to the minimum rectangle needed to display the content at that time, memory usage went down to 40-60MB.  In short, don't make layer frame's larger than absolutely needed.