如题。
比如我创建一个CGImageRef。用完了我要释放,免得内存升高,我应该用哪个?
CGImageRef imageRef = [asset.defaultRepresentation fullScreenImage];
PHP中文网2017-04-17 14:27:45
release
is counter -1,, retain
is +1
Need it when you don’t need itrelease
阿神2017-04-17 14:27:45
1) First check whether you have called CGImageRelease
, CGImageCreate
or CGImageCreateCopy
before using CGImageRetain
. .
2) If not, it will crash. . .
For asset classes, actively adjusting this does not seem to be useful in reducing memory usage. . .
迷茫2017-04-17 14:27:45
If you need to release memory, of course call CGImageRelease. CGImageRelease sets the reference count to -1. When the reference count reaches 0, the system will release and reclaim the memory. The counterpart to this is retain +1. Although ARC is used more now, the author still needs to understand and learn about memory management.