iphone - UIColor leaking… need to release the object?

后端 未结 3 1419
日久生厌
日久生厌 2020-12-18 05:46

I have a bunch of lines like this on my app

UIColor *myColor = [UIColor colorWithRed:corR green:corG blue:corB alpha:1.0];

Instruments are

3条回答
  •  不思量自难忘°
    2020-12-18 06:16

    Don't release the object, you don't own it and you will eventually get crashes. UIColor is probably just caching these colors for you, and Instruments has no way of knowing this so it reports them as leaks (basically stuff that got created and you don't have a reference to anymore but hasn't been deallocated).

    Try running instruments for some time (using the simulator) and then sending a memory warning to see if UIColor will purge its cache. Either way, there isn't anything you can really do to fix leaks happening inside core frameworks, so don't try. Just make sure you're not actually leaking them somehow (like retaining them at some point and never releasing them).

提交回复
热议问题