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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T18:48:21+00:00 2026-06-03T18:48:21+00:00

I have some operations that are inside blocks. This operations, only update an UIImage

  • 0

I have some operations that are inside blocks. This operations, only update an UIImage like this:

^(UIImage *image) {
            self.myImage = image;
        }];

My image is calculated by accessing the internet with a NSURLConnection. When I receive the image from the internet, I call that block that is inside a NSMutableArray. So far so good. My issue is that when I have multiple images that have the same URL, instead of making multiple calls, I just add a new block to the NSMutableArray inside the class that handles the connection. This way, I make one single call, and update multiple images that share the URL. Everything works ok, the problem is that I am leaking blocks. I add the block like this to the NSMutableArray:

 if( (self = [super init]) ) 
    {
        self.connectionURL=url;
        self.arrayOfBlocks=[NSMutableArray array];
        [arrayOfBlocks addObject:completion];
    }
    return self;

This is when the connection class is initialized. This is when I need to add a new block to the NSMutableArray (I only add it, and that’s it):

[arrayOfBlocks addObject:completion];

This is when I finally receive the call back, and start executing the blocks:

 for (MyBlock blockToExecute in arrayOfBlocks)
    {
        blockToExecute([UIImage imageWithData:data]);
    }

The problem is that this is leaking somehow. I am not able to counteract using releases or auto-releases because I am on ARC environment. So what could be a solution?


enter image description here

  • 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-03T18:48:22+00:00Added an answer on June 3, 2026 at 6:48 pm

    This is a well-known leak in Apple’s frameworks. It isn’t caused by your use of blocks.

    Here’s a previous question about it and a bug report.

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

Sidebar

Related Questions

I have bat-file, that make some operations. How to run this file from Delphi
I have some destructive operations that need confirmation, and I'm using the UIActionSheet. Inside
I have a php that makes some maintenance operations in my web and I
I have a set of objects I'd like to do some operations on, in
I have to do a background process which will perform some operations.. while this
Hi I'm testing some CRUD operations in Nhibernate. I have 3 tests in this
We have a class library that does some basic operations similar to an ORM,
I have some data inside this variable and I want to know how could
Suppose I have a function in a single threaded program that looks like this
I have some expensive test setup that is only necessary for a handful of

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.