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 8619981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:28:16+00:00 2026-06-12T06:28:16+00:00

I have a problem with objects allocation and release. I’m working on some app

  • 0

I have a problem with objects allocation and release.
I’m working on some app with image editing feature.
When user taps to pick an image, then UIImagePickerController is presented, then when user picks the image from the library, UIImagePickerController dismisses and then there is a method:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    //some logic

    FilterViewController *filterViewController = [[FilterViewController alloc] initWithImage:imageToWorkWith
                                                                                    withDelegate:self];

        /* present image processing screen, then release it */
        [((UIViewController *)self.delegate) presentModalViewController:filterViewController animated:NO];            
        [filterViewController release];
}

Then appears FilterViewController – the image editing screen. After tapping the “Done” button, the next method will be called:

- (void)dismissWithDone {
    [self.filterViewDelegate doneImageEdittingWithImage:self.imageToWorkWithView.image];
}

which invokes:

#pragma mark - FilterViewDelegate

- (void)doneImageEdittingWithImage:(UIImage *)imageToSend {
    //some logic

    [((UIViewController *)self.delegate) dismissModalViewControllerAnimated:NO];
}

All seems to work properly, but the problem is, that filterViewController is not deallocating and persist in memory. And if I will choose to edit some photo one more time, I mean if method with creation of filterViewController will be invoked one more time, then the previous instance will be deallocated and the new one will be presented, and so on.
I think that when [UIViewController setChildModalViewController:] is invoked, the previous instance of filterViewController is deallocated then, when it sets the new instance.
In case of adding one more release:

[((UIViewController *)self.delegate) presentModalViewController:filterViewController animated:NO];            
[filterViewController release];
[filterViewController release];

then it will be deallocated after dismissing, but on creating of new instance will be bad_access, cause it will try to dealloc the deallocated instance.

What I do not understand:
1. Why after dismissing of filterViewController, there is still reference count greater than 0 on it, that causes not to dealloc it?
2. Why, in case of adding one more release, the reference of deallocated object still persists in childModalViewController?

  • 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-12T06:28:17+00:00Added an answer on June 12, 2026 at 6:28 am

    The cause for all the troubles that I had here was, that I was not setting to nil certain property of block in certain class that I used in that UIViewController. For instance: I use GPUImage framework in this UIViewController, and I’m setting block:

    self.movieWriter.completionBlock = ^{
        //do something with self.* properties
        [self someMethod];
    }
    

    So, I was not setting nil to clean this block property before dismissing the UIViewController:

    self.movieWriter.completionBlock = nil;
    

    and that was the reason, that dealloc was not invoked on UIViewController.

    In addition here is explanation about blocks and why we need to set theirs properties to nil.

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

Sidebar

Related Questions

The problem is: I have a list of objects, with some containing the same
I have a problem with Map objects, while using Gravity. All messages works ok,
Hello I have problem to put together animations of two separate objects to second
I have a problem with django model objects where I have overridden __hash__ ()
I have a problem with Ebean. I have the usual Objects PsecUser, PsecRoles and
I have an odd problem with Django. I have a set of objects that
My problem is as follows. I have an array of objects in the form
I'm having a problem. I have the list of JSON objects in a separate
I have a problem with an app that takes an XML feed, parses it,
Im working inside a SSIS package. I have some C# script for placing Table

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.