Search code examples
iosdebuggingmemoryuiviewcalayer

How to debug large UIView memory allocation


I am trying to reduce memory usage in my app, and analysis with Instruments shows that a UIView drawLayer:inContext: is allocating 2.25 MB. I assume the allocation is done right before my code is called, and is due to an incorrect UIView or CALayer size somewhere. But none of my code is involved in the allocation (see picture below), therefore I have no idea how I can debug this. I have already checked all my views and layers, I think, and I do not see anything wrong.

Any ideas are appreciated!

enter image description here


Solution

  • Don't worry. The system is allocating a backing store for the layer which happens to be 640 * 960 * 4 bytes.

    If you don't leak the layer or view, you'll get your bytes back eventually, at the moment your view is unloaded.