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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:02:48+00:00 2026-05-30T07:02:48+00:00

I have created a class to download images from web. Issue is there is

  • 0

I have created a class to download images from web. Issue is there is a memory leak in it. Since this has been called multiple times. All the images getting downloaded are being called using this method. Since there are unlimited source of images the leak is mounting up.

Stack Trace is not showing any leak from code except main.

Leaked Object: Malloc 144, 176, 128, 160 bytes.

Resposible Library: CFNetwork

Responsible Frame: createCanonicalURL

Stack Trace:

   0 CFNetwork createCanonicalURL
   1 CFNetwork HTTPProtocol::_createMutableCanonicalRequest(__CFAllocator const*, _CFURLRequest const*, void const*)
   2 CFNetwork HTTPProtocol::_createCanonicalRequest(__CFAllocator const*, _CFURLRequest const*, void const*)
   3 CFNetwork HTTPProtocol::copyCanonicalRequest()
   4 CFNetwork URLConnectionLoader::copyProtocolCanonicalRequest()
   5 CFNetwork URLConnectionClient::getRequestForTransmission(unsigned char, _CFURLResponse*, _CFURLRequest const*, __CFError**)
   6 CFNetwork URLConnectionClient::_clientWillSendRequest(_CFURLRequest const*, _CFURLResponse*, URLConnectionClient::ClientConnectionEventQueue*)
   7 CFNetwork URLConnectionClient::ClientConnectionEventQueue::processAllEventsAndConsumePayload(XConnectionEventInfo<XClientEvent, XClientEventParams>*, long)
   8 CFNetwork URLConnectionClient::processEvents()
   9 CFNetwork MultiplexerSource::perform()
  10 CoreFoundation __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
  11 CoreFoundation __CFRunLoopDoSources0
  12 CoreFoundation __CFRunLoopRun
  13 CoreFoundation CFRunLoopRunSpecific
  14 CoreFoundation CFRunLoopRunInMode
  15 GraphicsServices GSEventRunModal
  16 GraphicsServices GSEventRun
  17 UIKit UIApplicationMain
  18 Interior News main /iPhone Ongoing Projces/WAN_Interiors/Latest_Interior_News_V_1_2/Latest_Interior_News/main.m:14
  19 Interior News start

connection object is properly released.

This is also coming in Device too. Most of them say its a bug in NSURLConnection, some say there is work araound adn some say not

I have tried setting as most mentioned

[[NSURLCache sharedURLCache] setMemoryCapacity:0];
[[NSURLCache sharedURLCache] setDiskCapacity:0];

but no use…

Please advice

Code

if (connectionForImage==nil) 
    {

        NSString * fullImagePath = [rootURLForImage stringByAppendingPathComponent:imagePath];
        NSString * trimedstring = [fullImagePath stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
        NSString * percentEscapedUrl = [trimedstring stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];



        NSLog(@"Trimmed :%@",trimedstring);
        NSLog(@"PercentEscaped %@",percentEscapedUrl);

        NSURLRequest * imageRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:percentEscapedUrl] cachePolicy:NSURLCacheStorageNotAllowed timeoutInterval:6.0];

        [[NSURLCache sharedURLCache] setMemoryCapacity:0];
        [[NSURLCache sharedURLCache] setDiskCapacity:0];



        connectionForImage =[[NSURLConnection alloc] initWithRequest:imageRequest delegate:self];


    }

Connection for image is getting released at connection did finish load and error.

  • 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-05-30T07:02:49+00:00Added an answer on May 30, 2026 at 7:02 am

    I tried ASIHTTPRequest thenI encountered a badurl error. I checked the url It seemed to be of format http:/www.example.com instead of http://www.example.com later found out that the code

    NSString * fullImagePath = [rootURLForImage stringByAppendingPathComponent:imagePath];
    was the issue.

    it was the one which was remoging the slash from http://
    so changed my code to

     NSString * fullImagePath = [rootURLForImage stringByAppendingPathComponent:imagePath];
            NSString * trimedstring = [imagePath stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
            NSString * percentEscapedUrl = [trimedstring stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    
    
            NSURL * rootURL = [NSURL URLWithString:rootURLForImage];
            NSURL * finalURL = [NSURL URLWithString:percentEscapedUrl relativeToURL:rootURL];
    
            NSURLRequest * imageRequest = [NSURLRequest requestWithURL:finalURL cachePolicy:NSURLCacheStorageNotAllowed timeoutInterval:60.0];
    
            [[NSURLCache sharedURLCache] setMemoryCapacity:0];
            [[NSURLCache sharedURLCache] setDiskCapacity:0];
    
    
    
            connectionForImage =[[NSURLConnection alloc] initWithRequest:imageRequest delegate:self];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a class which extends Gallery. There is no onCreate() method in
I have created a class derived from NSImageView. However, the classes's constructor (init) is
Android:How to display images from the web in a ListView?I have the following code
I have used following code for download some files from our internet. public class
I am following the guide at http://guides.rubyonrails.org/association_basics.html and I have created class Customer <
I have created a class which extends View class. public class SplashScreen extends View
I have created a class called Class1, and in another module, I want to
I have created one class as public class FormActivity extends Activity { TextView tv
I have created a class for fetching server-side data in my iOS-App, based on
I have created a class library called AddServiceLibrary in which I have a method

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.