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

  • Home
  • SEARCH
  • 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 612901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:56:35+00:00 2026-05-13T17:56:35+00:00

Background: Inspired from Apple’s sample code ScrollViewSuite, I’ve created a view controller class that

  • 0

Background:

Inspired from Apple’s sample code ScrollViewSuite, I’ve created a view controller class that shows picture thumbnails and one selected picture. The hierarchy of controls for the “selected” picture is something like this:

--> UIView
    --> UIScrollView
        --> UIImageView

Following code is used to put the UIScrollView onto the view:

imageScrollView = [[UIScrollView alloc] initWithFrame:frame];
[imageScrollView setBackgroundColor:[UIColor clearColor]];
[imageScrollView setDelegate:self];
[imageScrollView setBouncesZoom:YES];
[[self view] addSubview:imageScrollView];

… and following code is used to configure and add UIImageView to the UIScrollView:

// Custom method to return a UIImage from a URL string
UIImage *image = [UIImage newImageWithContentsOfURL:imageURL];  

// first remove previous image view, if any
[[imageScrollView viewWithTag:MAIN_IMAGE_TAG] removeFromSuperview];

// set the new image view
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
[imageView setDelegate:self];
[imageView setTag:MAIN_IMAGE_TAG];
[imageScrollView addSubview:imageView];
[imageScrollView setContentSize:[imageView frame].size];

// choose minimum scale so image width fits screen
float minScale  = [imageScrollView frame].size.width / [imageView frame].size.width;
[imageScrollView setMinimumZoomScale:minScale];
[imageScrollView setZoomScale:minScale];
[imageScrollView setContentOffset:CGPointZero];

// clear memory
[imageView release];
imageView = nil;

[image release];
image = nil;

Here’s the category method I’ve used to get UIImage using URL string:

+ (UIImage *)newImageWithContentsOfURL:(NSString *)imageURL {   
    NSURL *url = [[NSURL alloc] initWithString:imageURL];
    NSData *data = [[NSData alloc] initWithContentsOfURL:url];
    UIImage *image = [[UIImage alloc] initWithData:data];
    [data release];
    [url release];

    return image;
}

Problem:
The affect of loading a jpeg image of size 110 Kb (approx.) is that the real memory of the application jumps from 12 MB (approx.) to 38 MB (approx.). I was baffled when i first saw this. How is this possible? Uh, and the end result: Application crashes on iPhone 3G (occasionally).

Note that the memory readings were taken using Memory Monitor tool in Instruments – while testing the application on the device (not the simulator). Also note that Instruments show no memory leaks, and Static Analyzer doesn’t point to anything suspicious either.

I need help!

  • 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-13T17:56:35+00:00Added an answer on May 13, 2026 at 5:56 pm

    Could it have something to do with the fact that a jpeg is compressed.
    It could be being uncompressed when being displayed, hence the huge jump in memory.

    What are the dimensions of the image at 1:1 scale?

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

Sidebar

Ask A Question

Stats

  • Questions 503k
  • Answers 503k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer no predefined way. The good news is that with 1.9.2,… May 16, 2026 at 2:48 pm
  • Editorial Team
    Editorial Team added an answer If the object is not going to be touched in… May 16, 2026 at 2:48 pm
  • Editorial Team
    Editorial Team added an answer Are you using a Service to handle this Socket connection… May 16, 2026 at 2:48 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Background I have a web app that will create an image from user input.
Background: I have a little video playing app with a UI inspired by the
I have a program that will analyzes source code. It can recursively go through
Somewhat inspired by this question about a graphical programming environment. I don't think that
Background: writing an automated release script to export changed files between versions from SVN
Inspired by this question where there are differing views on SET NOCOUNT... Should we
I have been working on a project that dynamically creates a javascript file using
Background The Von-Neumann architecture describes the stored-program computer where instructions and data are stored
Inspired by a recent TED talk , I want to write a small piece
Background: I am attempting to do a couple of unit tests on AJAX requests

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.