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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:42:03+00:00 2026-05-26T17:42:03+00:00

My code take a lot time to load images from gallery. I store url

  • 0

My code take a lot time to load images from gallery. I store url of each image in database and then load them from gallery using AssetsLibrary framework. But i notice that it take more memory and so that i receive memory warning. after some time app is crash down. Here i put my code.

-(void) nextImageLoad
{
//    ALAssetsLibrary* self. assetslibrary=[[ALAssetsLibrary alloc] init];
    self.myScrollView.pagingEnabled=YES;
    NSLog(@"current :- %d, loaded_photo :- %d, [imageData count] :- %d",current, loaded_photo, [imageData count]);

    if(current>loaded_photo && current < [imageData count])
    {
        ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myasset)
        {
            self.rep = [myasset defaultRepresentation];
            CGImageRef iref = [self.rep fullResolutionImage];
            if (iref) 
            {

                UIImageView *temp = [[UIImageView alloc] initWithFrame:CGRectMake(self.x, y, 300, 300)];
                temp.image=[UIImage imageWithCGImage:iref];     

                [self.myScrollView addSubview:temp];
                [temp release];


                [myScrollView setContentSize:CGSizeMake(self.x+600, 410)];
                [myScrollView setAutoresizesSubviews:YES];

            }
            else
            {

            }
        };

        ALAssetsLibraryAccessFailureBlock failureblock  = ^(NSError *myerror)
        {
            NSLog(@"booya, cant get image - %@",[myerror localizedDescription]);
        };

        [self.assetslibrary assetForURL:[NSURL URLWithString:[[self.imageData objectAtIndex:current] valueForKey:@"photo_url"] ]
                       resultBlock:resultblock
                      failureBlock:failureblock];
         self.x=self.x+320;
        loaded_photo= loaded_photo+1;
    }



}

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
    lastContentOffset = scrollView.contentOffset.x;
}
-(void) scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
    if (lastContentOffset > scrollView.contentOffset.x)
    {        
        NSLog(@"left");   
        if(current>0)
        current=current-1;
    }
    else if (lastContentOffset < scrollView.contentOffset.x) 
    {
        NSLog(@"right");
        current=current+1;
        [self nextImageLoad];        

    }
    lastContentOffset = scrollView.contentOffset.x;


}
  • 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-26T17:42:04+00:00Added an answer on May 26, 2026 at 5:42 pm

    Hard to know if this is the problem, but try creating an autorelease pool inside all your blocks:

    block = ^(ALAsset *myasset)
    {
      NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    
      // rest of block here
    
      [pool release];
    }
    

    Also remember if you return early inside the block, you need to release the pool object before your return statement.

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

Sidebar

Related Questions

I've been told that every COM method callable from C++ code (take for instance
I have the following code to take an image and generate the thumbnail. how
Well I am using the following code to take any old image into a
Take this code snippet for example: window.location.href = 'mysite.htm#images'; Already being on the site
I have the following code to take screenshots of a window: HDC WinDC; HDC
I have the following code to take a screenshot of a window, and get
Here's a piece of code to take a string (either NSString or NSAttributedString) input
Take this code: <?php if (isset($_POST['action']) && !empty($_POST['action'])) { $action = $_POST['action']; } if
Let's take the code int a, b, c; ... if ((a + b) >
Take this code into consideration: Proxy p = new Proxy(Type.SOCKS, new InetSocketAddress(proxyURL, port)); try

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.