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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:32:11+00:00 2026-05-14T14:32:11+00:00

the image that is being displayed in this code is leaking but I cant

  • 0

the image that is being displayed in this code is leaking but I cant figure out how. What I have a tableview that displays images to be displayed. Each time a user selects an image, it should remove the old image, download a new one, then add it to the scroll view. But the old image is not being released and I cant figure out why…

-(void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [imageView removeFromSuperview];
    self.imageView = nil;
    NSUInteger row = [indexPath row];

    NSString *tempC = [[NSString alloc]initWithFormat:@"http://www.website.com/%@_0001.jpg",[pdfNamesFinalArray objectAtIndex:row] ];
    chartFileName = tempC;
    pdfName = [pdfNamesFinalArray objectAtIndex:row];

    [tableView deselectRowAtIndexPath:indexPath animated:YES];

    NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
                                                         NSUserDomainMask, YES);
    NSString *docsPath = [paths objectAtIndex:0];
    NSString *tempString = [[[NSString alloc]initWithFormat:@"%@/%@.jpg",docsPath,pdfName]autorelease];
    NSData *data = [NSData dataWithContentsOfFile:tempString];

    if (data != NULL){
        self.imageView = nil;
        [imageView removeFromSuperview];
        self.imageView = nil;
        UIImageView *tempImage = [[[UIImageView alloc]initWithImage:[UIImage imageWithData:data]]autorelease];
        self.imageView = tempImage;
        [data release];
        scrollView.contentSize = CGSizeMake(imageView.frame.size.width , imageView.frame.size.height);
        scrollView.maximumZoomScale = 1;
        scrollView.minimumZoomScale = .6;

        scrollView.clipsToBounds = YES;
        scrollView.delegate = self;

        [scrollView addSubview:imageView];
        scrollView.zoomScale = .37;

    }

    else {
        [data release];
        self.imageView = nil;
        [imageView removeFromSuperview];
        self.imageView = nil;
        activityIndicator.hidden = NO;
        getChartsButton.enabled = NO;
        chartListButton.enabled = NO;
        saveChartButton.enabled = NO;
        [NSThread detachNewThreadSelector:@selector(downloadImages) toTarget:self withObject:nil];



    }
chartPanel.hidden = YES;



}

-(void) downloadImages {

    NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
    self.imageView = nil;
    [imageView removeFromSuperview];
    NSURL *url = [[[NSURL alloc]initWithString:chartFileName]autorelease];
    NSData *data = [NSData dataWithContentsOfURL:url];

    UIImageView *tempImage = [[[UIImageView alloc]initWithImage:[UIImage imageWithData:data]]autorelease];
    self.imageView = tempImage;
    tempImage = nil;

    scrollView.contentSize = CGSizeMake(imageView.frame.size.width , imageView.frame.size.height);
    scrollView.maximumZoomScale = 1;
    scrollView.minimumZoomScale = .37;
    scrollView.clipsToBounds = YES;
    scrollView.delegate = self;
    [scrollView addSubview:imageView];
    scrollView.zoomScale = .6;

    activityIndicator.hidden = YES;
    getChartsButton.enabled = YES;
    chartListButton.enabled = YES;
    saveChartButton.enabled = YES;
    [pool drain];
    [pool release];
}
  • 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-14T14:32:11+00:00Added an answer on May 14, 2026 at 2:32 pm

    This looks wrong:

    self.imageView = nil;
    [imageView removeFromSuperview];
    

    You are setting imageView to nil before removing it from the superview, so the 2nd statement is really just [nil removeFromSuperview];, which isn’t going to do anything.

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

Sidebar

Related Questions

I have this background image that is 175x175 but I am trying to make
I have a problem where users are reporting that their images aren't being uploaded
I have an image that is served as static file using Nginx, but I
I'd like to get the image that is being displayed on the UIImagePickerController when
I have an html for using POST that is being used to rate images.
I have code that will check to see if an image is on the
I have some scientific image data that's coming out of a detector device in
I have some code on a php page that gets an image filename strips
My website has public-facing profiles. Users may have 145x145 profile images that are displayed
I'm trying to remove the background image on a page that's being loaded via

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.