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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:24:04+00:00 2026-05-31T22:24:04+00:00

This code generates Low memory warning because background 5 thread is almostly loading images

  • 0

This code generates Low memory warning because background 5 thread is almostly loading images in same time.

I want to give a priority each thread and make lock & unlock.
I would make step by step thread. image 1 loading -> image2 loading -> image3 loading -> image4 loading.

How can I do this?

viewcontroller

-(void)viewDidLoad
{            
 for(int i=0; i<screenshotcount ; i++)
 {
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];  
    NSString * url=[detailItem.mScreenshot objectAtIndex:i];
    NSDictionary *args=[NSDictionary dictionaryWithObjectsAndKeys:
                       [NSNumber numberWithInt:i], @"screenNum",
                       [NSString stringWithString:url],@"url",
                       nil];
    [self performSelectorInBackground:@selector(loadImageScreenshot:) withObject:args];
    [pool release]; 
  }
}

loading image

-(void) loadImageScreenshot:(NSDictionary *) args
{
 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 
 UIImage * screenshotImage=[UIImage imageWithStringURL:url];
 NSDictionary *args2=[NSDictionary dictionaryWithObjectsAndKeys:
                    [NSNumber numberWithInt:num], @"screenNum",
                    screenshotImage,@"image",
                    nil];                                                               

[self performSelectorOnMainThread:@selector(assignImageToScreenshotImageView:) withObject:args2  waitUntilDone:YES];
[pool release];
}

image add

- (void) assignImageToScreenshotImageView:(NSDictionary *)arg
{ 
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
UIImage * image= [arg objectForKey:@"image"];
UIImageView *imageview=[UIImageView alloc]init];
               .
               .
imageview.image=image;
[self.mScreenshotSpace addSubview:imageview];
[imageview release];
[pool release];
}

image from url

+(UIImage *)imageWithStringURL:(NSString *)strURL
{
 NSURL *url =[NSURL URLWithString:strURL];
 NSData *   data=[[NSData alloc]initWithContentsOfURL:url options:NSDataReadingUncached error:&error];

 UIImage * image=[UIImage imageWithData:data ];
 [data release];
 return image;
}
  • 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-31T22:24:06+00:00Added an answer on May 31, 2026 at 10:24 pm

    maybe I misunderstood your question, but from what you said, what you really want is to “serialise” the threads, that is, ensure they are executed one after the other. If this is the case I do not see a big advantage in having five (or more) threads if they spend most of the time waiting in a sort of “thread queue” 🙂
    My 2 cents: Instead of playing with the threads’ priority, maybe you should think about re-design the code to have a queue of files/images to load and a thread that dequeue and load the images one after the other. (the classic consumer/producer scenario)
    If you need to speed up things you might think to have another thread doing some pre-fetching (if that make sense in your sw design/architecture)

    CiaoCiao
    Sergio

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

Sidebar

Related Questions

Ok, this situation is a little weird but anyway. This PHP code generates several
I have this code (an example that PHP generates for me)... <select id=outsideBlue3> <option
I have code that generates this error: ** Message: pygobject_register_sinkfunc is deprecated (GstObject) Traceback
I have some LINQ code that generates a list of strings, like this: var
I have some C# code that generates google maps. This codes looks at all
This code has generated a 1 result for r on the 1st toss 200
I use this code to generate a random number. Random R = new Random(0);
This issue is somewhat related: Problem with Code Generated by XSD.EXE: Sequence of Elements
I have this code try { //AN EXCEPTION IS GENERATED HERE!!! } catch {
For real-time multimedia tasks the low latency is essential. A stable low latency value

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.