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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:35:05+00:00 2026-05-20T04:35:05+00:00

I am loading the images of size 450KB in UIImage view and then adding

  • 0

I am loading the images of size 450KB in UIImage view and then adding it to UIscrollview. while am scrolling the 30 images continously,its getting crashed.. what may be the reason..is this memory leak issue…or image size is the problem…? thanks in advance..

here is my code ..

@try{

NSAutoreleasePool *pool;
pool = [[NSAutoreleasePool alloc] init];

//NSArray *array = [global_ContentString componentsSeparatedByString:@"@@#"];
    NSArray *array1 = [catalogURL componentsSeparatedByString:@"&"];
    //**NSLog(@"array1******  = %@",array1);
    NSLog(@"loading catalog image(method: loadCatalogImage).......%@%@",baseURL, [[[array1 objectAtIndex:0] componentsSeparatedByString:@"##"] objectAtIndex:0]); 

    //NSLog(@"baseURL = %@",baseURL);
    NSLog(@"loading catalog image.......%@%@",baseURL, [[[array1 objectAtIndex:0] componentsSeparatedByString:@"##"] objectAtIndex:0]); 

    zoomedImageURL = [NSString stringWithFormat:@"%@%@", baseURL, [[[array1 objectAtIndex:0] componentsSeparatedByString:@"##"] objectAtIndex:1]];

    [zoomedImageURL retain];

    NSLog(@"aaaaaaaaaaaaaa = %@",zoomedImageURL);
    //UIImage *img = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",baseURL, [[[array1 objectAtIndex:0] componentsSeparatedByString:@"##"] objectAtIndex:0]]]]];
    UIImage *img = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",zoomedImageURL]]]];

    imgView.contentMode = UIViewContentModeScaleAspectFit;
    imgView.image = img;//[GPSTripTracking generatePhotoThumbnail:img:109]; 

[pool release];

[global_imgProgress stopAnimating];

}
@catch (NSException *e) {
    [global_imgProgress stopAnimating];
    NSLog(@"Exception....");
}
@finally {

}   

am releasing my imgView in dealloc method..

i imlemented the following code in “scrollviewdidscroll”

- (void)scrollViewDidScroll:(UIScrollView *)sender {
// We don't want a "feedback loop" between the UIPageControl and the scroll delegate in
// which a scroll event generated from the user hitting the page control triggers updates from
// the delegate method. We use a boolean to disable the delegate logic when the page control is used.
if (pageControlUsed) {
    // do nothing - the scroll was initiated from the page control, not the user dragging
    //pageText.text = [NSString stringWithFormat:@"%d/%d", (pageControl.currentPage +1), pageControl.numberOfPages];
    pageText.text = [NSString stringWithFormat:@"%d/%d", (pageControl.currentPage ), pageControl.numberOfPages];
    //NSLog(@"not scrollling page....");
    return;
}


// Switch the indicator when more than 50% of the previous/next page is visible
CGFloat pageWidth = scrollView.frame.size.width;
int page = floor((scrollView.contentOffset.x - pageWidth / 2) / pageWidth) + 1;
pageControl.currentPage = page;

// load the visible page and the page on either side of it (to avoid flashes when the user starts scrolling)
[self loadScrollViewWithPage:page - 1];
[self loadScrollViewWithPage:page];
[self loadScrollViewWithPage:page + 1];
//NSLog(@"scrolling page....%d", page);

// A possible optimization would be to unload the views+controllers which are no longer visible

}

and my code for ” loadScrollViewWithPage” is

- (void)loadScrollViewWithPage:(int)page 

{
//page–;

if (page < 0) return;
if (page >= numberOfPages) return;



if(!isViewCatalog && searchId == 1)
{
    //NSLog(@"curre page = %d",pageControl.currentPage);
    NSArray *array1 = [global_ContentString componentsSeparatedByString:@"@@#"];
    if(searchInCatalogFlag == 1)
    {
        pageControl.currentPage=0;
        NSArray *urlArray = [[array1 objectAtIndex:pageControl.currentPage] componentsSeparatedByString:@"##"];
        //NSLog(@"url array** = %@",urlArray);

        headerText.text = [NSString stringWithString:[urlArray objectAtIndex:0]];

        pageText.text = [NSString stringWithFormat:@"%d/%d",  pageControl.currentPage, (pageControl.numberOfPages - 1)];

    }
    else

    {
    NSArray *urlArray = [[array1 objectAtIndex:pageControl.currentPage] componentsSeparatedByString:@"##"];
    //NSLog(@"url array** = %@",urlArray);
    headerText.text = [NSString stringWithString:[urlArray objectAtIndex:0]];

    pageText.text = [NSString stringWithFormat:@"%d/%d",  pageControl.currentPage, (pageControl.numberOfPages - 1)];
    }
        if(page == selectedPage && ![global_imgProgress isAnimating])
        [global_imgProgress startAnimating];
}
else
{
    headerText.text = [NSString stringWithString:global_SelectedCatalogName];
    pageText.text = [NSString stringWithFormat:@"%d/%d",  (pageControl.currentPage + 1), (pageControl.numberOfPages - 1)];
    if(page == selectedPage + 1 && ![global_imgProgress isAnimating] )
        [global_imgProgress startAnimating];
//  NSLog(@"header text = %@", headerText.text);    
    //headerText.text = [NSString stringWithString:[urlArray objectAtIndex:0]];
}


FullPageView *controller = [viewControllers objectAtIndex:page];
if ((NSNull *)controller == [NSNull null] ) {

    //NSLog(@"Loading page =========== %d, %d", page, selectedPage);
    //voucherPageNo = page;
    //[voucherImage retain];
    if(universalApp==2)
    {
    controller = [[FullPageView alloc] initWithNibName:@"FullPageView_iphone" bundle:nil];//:page];
    [controller.view setFrame:CGRectMake(0, 0, 320,332)];
    }
    else
    {
    controller = [[FullPageView alloc] initWithNibName:@"FullPageView" bundle:nil];//:page];
    [controller.view setFrame:CGRectMake(0, 192, 768, 691)];
    }
    //[controller.view setFrame:CGRectMake(0, 0, 320,480)];
    //[controller.view setFrame:CGRectMake(0, 192, 768, 691)];
    if((!isViewCatalog && searchId < 2 && searchInCatalogFlag == 0))// || searchInCatalogFlag == 1)
    {
    //  NSLog(@">>>>>>>>>>>>>>>>>> LOADING IMAGE >>>>>>>>>>>>>>>>>>>>");
        [controller setPageNo:page];
    //  if(page >= selectedPage - 1)
            [NSThread detachNewThreadSelector:@selector(loadImage) toTarget:controller withObject:nil]; 

    }
    else //if((page >= (selectedPage - 1) && page <= (selectedPage + 1)) || !isFirstTimeLoading)
    {
        NSLog(@"Loading CATALOG IMAGE = %d, %d, %@", page, selectedPage, (isFirstTimeLoading ?@"YES" : @"NO"));
        [controller setCatalogURL:[NSString stringWithFormat:@"%@", [catalogArray objectAtIndex:page+(searchId< 2 && !isViewCatalog && searchInCatalogFlag == 0?0:1)]]];
        NSLog(@"loading image ipad= %@", [catalogArray objectAtIndex:page+(searchId< 2 && !isViewCatalog && searchInCatalogFlag == 0?0:1)]);
        //  if(page >= selectedPage - 1)
            [NSThread detachNewThreadSelector:@selector(loadCatalogImage) toTarget:controller withObject:nil];  
    //  if(page == (selectedPage + 1))
            //isFirstTimeLoading = NO;

    }
    [viewControllers replaceObjectAtIndex:page withObject:controller];
     [controller release];


        }


// add the controller's view to the scroll view
if (nil == controller.view.superview) 
{

//  NSLog(@"Voucher view addead at page..... %d", page);
    CGRect frame = scrollView.frame;
    frame.origin.x = frame.size.width * page;
    frame.origin.y = 0;
    controller.view.frame = frame;
//  NSLog(@">>>>>>>>> %f, %f", frame.size.width, frame.origin.x);

    [scrollView addSubview:controller.view];

}
//if(page == pageControl.currentPage)
    //[imgProgress startAnimating]; 


//else

//pageControlUsed = YES;

}
where wil be the problem..?

  • 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-20T04:35:06+00:00Added an answer on May 20, 2026 at 4:35 am

    It very likely that your program gets terminated by iOS because it consumes too much memory. Start it from XCode and look at the console – it will probably print that it receives memory warnings.

    You will have to load the images on demand, i.e. only when the user gets close to seeing them, and you will have to release the ones that move out of view again. To that end, implement the

    - (void)scrollViewDidScroll:(UIScrollView *)scrollView
    

    delegate method, look at the scroll view’s content offset and load/release the appropriate images. Alternatively, you can choose to not release them there but instead wait for a memory warning to do so. To do so, implement the

    - (void)didReceiveMemoryWarning
    

    method in your view controller.

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

Sidebar

Related Questions

I am loading images of size 1800x1300 in UIImage.(getting the images from server..)then i
I am loading images of different size and then images are scaled and border
Loading images into Flex (size < 100kb) causes IE7 memory increase by a megabyte
So I'm loading images from a web service, but the size of the images
I have to design splash screens(images that fit screen while loading) for android application
I am loading images into a div, and then initiating a carousel to the
Having some annoying issues with loading images into a BufferedImage (image in the example)
I am using following code for loading images from server using following code.When i
I have a situation where I'm lazy loading images from the www. It's a
I am using JSF and have made a custom servlet for loading images dynamically.

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.