Abdelrahman Abdelrahman - 2 years ago 161
Objective-C Question

How to fix terminated due to memory issue when using UIGraphicsGetImageFromCurrentImageContext?

In my drawing app I'm using UIImage to cache drawing on it.

The following line of code cause a memory issue:

UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, 0.0);
self.cacheImage = UIGraphicsGetImageFromCurrentImageContext();

How can I use
without causing memory leaks ?

Any help will be appreciated. Thanks in advance.

Answer Source

Use this may be it help you. It help me in my case

 @autoreleasepool {
  // Write your code here    
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download