Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8535629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:28:35+00:00 2026-06-11T10:28:35+00:00

I am using the followinf code for applying image filters. This is working fine

  • 0

I am using the followinf code for applying image filters. This is working fine on scaled down images.
But when I apply more than 2 filters on full resolution images, the app crashes. A memory warning is received.

When I open the ‘allocations’ instrument, I see that CFData(store) takes up most of the memory used by the program.
When I apply more than 2 filters on a full resolution image, the ‘overall bytes’ go upto 54MB. While the ‘live bytes’ don’t seem to reach more than 12MB when I use my eyes on the numbers as such, but the spikes show that live bytes also reach upto this number and come back.

Where am i going wrong?

- (UIImage *)editImage:(UIImage *)imageToBeEdited tintValue:(float)tint 
{ 
CIImage *image = [[CIImage alloc] initWithImage:imageToBeEdited]; 
NSLog(@"in edit Image:\ncheck image: %@\ncheck value:%f", image, tint); 

[tintFilter setValue:image forKey:kCIInputImageKey]; 
[tintFilter setValue:[NSNumber numberWithFloat:tint] forKey:@"inputAngle"]; 

CIImage *outputImage = [tintFilter outputImage]; 
NSLog(@"check output image: %@", outputImage); 
return [self completeEditingUsingOutputImage:outputImage]; 
} 

- (UIImage *)completeEditingUsingOutputImage:(CIImage *)outputImage 
{ 
CGImageRef cgimg = [context createCGImage:outputImage fromRect:outputImage.extent]; 
NSLog(@"check cgimg: %@", cgimg); 
UIImage *newImage = [UIImage imageWithCGImage:cgimg]; 
NSLog(@"check newImge: %@", newImage); 
CGImageRelease(cgimg); 
return newImage; 
} 

Edit:
I also tried making cgimg as nil. Didn’t help.
I tried putting context declaration and definition inside the 2nd function. Didn’t help.
I tried to move declarations and definitions of filters inside the functions, didn’t help.

AlsoCrash happens at

CGImageRef cgimg = [context createCGImage:outputImage fromRect:outputImage.extent]; 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T10:28:36+00:00Added an answer on June 11, 2026 at 10:28 am

    the cgimg i was making took most of the space in memory and was not getting released.

    I observed that calling the filer with smaller values takes the CFData (store) memory value back to a samller value, thus avoiding the crash.

    So I apply filter and after that call the same filter with image as ‘nil’. This takes memory back to 484kb or something from 48 MB after applying all 4 filters.

    Also, I am applying this filters on a background thread instead of the main thread. Applying on main thread again causes crash. Probably it doesn’t get enough time to release the memory. I don’t know.
    But these things are working smoothly now.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using following code to show a spinning wheel: $(#loading) .hide() .ajaxStart(function(){ $(this).show();
I am using following code to get bitmap from url. This function is used
I am using following code to get source for image in wpf (image is
So I'm applying an image mask to a UIView layer with the following code:
I am using following code to add tabs on a tabHost but crashes on
This is how we display and process an Image using Opencv: int _tmain(int argc,
Consider a normal PHP image upload functionality (not using AJAX) and there occurs this
I'm using this following jquery code to insert the responsetext in the div. $(#div).load('page.php?val='+myvalue)
I'm using Linq to entities applying a Table per Type approach. This has been
Using following code I try to get updated list of checkbuttons' corresponding text values,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.