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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T23:43:33+00:00 2026-05-11T23:43:33+00:00

I am creating an application for the iPhone which involves having more than one

  • 0

I am creating an application for the iPhone which involves having more than one button which all animate the same UIImageView. It works well in the simulator, (like practically all apps) but when it comes to the device it plays the animation well, but with repetitive pressing of the buttons the app quits. So far I have implemented 2 buttons. Here’s what happens when they are pressed.
Okay, I have 44 MB of ram available when my app starts, Then when I press the first of 2 buttons that start an animation the available memory goes down to 31 and climbs up to 32, then when I press the second button the available memory goes down to 9 then climbs to 24 and then strangely declines to 10 slowly. If the first button is then pressed then the available memory climbs to 14MB And under repetitive pressing of these buttons the apps memory goes down to 4 to 3 MB and quits. In instruments there are no leaks. Here is my code incase anyone can spot where my memory issue lurks. (BTW, I’m still developing on 2.2.1 because if I upgrade to 3.0 i won’t be able to test my apps on the device as I am not enrolled in the apple developer program yet and I followed an online tutorial to get apps onto the device that only works with 2.2.1)

 @synthesize 123pig;
    - (IBAction)startClick:(id)sender{
    animationTimer = [NSTimer scheduledTimerWithTimeInterval:(1.00/30.00) target:self selector:@selector(tick) userInfo:nil repeats:NO];

        123pig.animationImages = [NSArray arrayWithObjects:
                                [UIImage imageNamed: @"123pigapple0001.png"],
                                 [UIImage imageNamed: @"123pigapple0002.png"],
                                 [UIImage imageNamed: @"123pigapple0003.png"],
                                 [UIImage imageNamed: @"123pigapple0004.png"],
                                  [UIImage imageNamed: @"123pigapple0005.png"],
                                  [UIImage imageNamed: @"123pigapple0006.png"],
                                  [UIImage imageNamed: @"123pigapple0007.png"],
                                  [UIImage imageNamed: @"123pigapple0008.png"],
                                  [UIImage imageNamed: @"123pigapple0009.png"],
                                  [UIImage imageNamed: @"123pigapple0010.png"],
                                  [UIImage imageNamed: @"123pigapple0011.png"],
                                  [UIImage imageNamed: @"123pigapple0013.png"],
                                  [UIImage imageNamed: @"123pigapple0014.png"],
                                  [UIImage imageNamed: @"123pigapple0015.png"],
                                  [UIImage imageNamed: @"123pigapple0016.png"],
                                  [UIImage imageNamed: @"123pigapple0017.png"],
                                  [UIImage imageNamed: @"123pigapple0018.png"],
                                  [UIImage imageNamed: @"123pigapple0019.png"],
                                  [UIImage imageNamed: @"123pigapple0020.png"],nil];

        [123pig setAnimationRepeatCount:1];
        123pig.animationDuration =.7;
        [123pig startAnimating];
}

    - (void)tick{
    [self animatePig];
}

    - (void)animatePig{

    UIImage *pigImage13=[UIImage imageNamed:@"123pigapple0020.png"];


    if(123pig.image == pigImage13)
        123pig.image = pigImage13;
    else
        123pig.image = pigImage13;






    }
    - (IBAction)startClick1:(id)sender{
    animationTimer1 = [NSTimer scheduledTimerWithTimeInterval:(1.00/30.00) target:self selector:@selector(tick1) userInfo:nil repeats:NO];
        123pig.animationImages = [NSArray arrayWithObjects:
                              [UIImage imageNamed: @"123pig0015.png"],
                              [UIImage imageNamed: @"123pig0016.png"],
                              [UIImage imageNamed: @"123pig0017.png"],
                              [UIImage imageNamed: @"123pig0018.png"],
                              [UIImage imageNamed: @"123pig0019.png"],
                              [UIImage imageNamed: @"123pig0020.png"],
                              [UIImage imageNamed: @"123pig0021.png"],
                              [UIImage imageNamed: @"123pig0022.png"],
                              [UIImage imageNamed: @"123pig0023.png"],
                              [UIImage imageNamed: @"123pig0024.png"],
                              [UIImage imageNamed: @"123pig0025.png"],
                              [UIImage imageNamed: @"123pig0026.png"],
                              [UIImage imageNamed: @"123pig0027.png"],
                              [UIImage imageNamed: @"123pig0028.png"],
                              [UIImage imageNamed: @"123pig0029.png"],
                              [UIImage imageNamed: @"123pig0030.png"],
                              [UIImage imageNamed: @"123pig0031.png"],
                              [UIImage imageNamed: @"123pig0032.png"],
                              [UIImage imageNamed: @"123pig0033.png"],
                              [UIImage imageNamed: @"123pig0034.png"],
                              [UIImage imageNamed: @"123pig0035.png"],
                              [UIImage imageNamed: @"123pig0036.png"],
                              [UIImage imageNamed: @"123pig0037.png"],
                              [UIImage imageNamed: @"123pig0038.png"],
                              [UIImage imageNamed: @"123pig0039.png"],
                              [UIImage imageNamed: @"123pig0040.png"],
                              [UIImage imageNamed: @"123pig0041.png"],
                              [UIImage imageNamed: @"123pig0042.png"],
                              [UIImage imageNamed: @"123pig0043.png"],
                              [UIImage imageNamed: @"123pig0044.png"],
                              [UIImage imageNamed: @"123pig0045.png"],
                              [UIImage imageNamed: @"123pig0046.png"],
                              [UIImage imageNamed: @"123pig0047.png"],
                              [UIImage imageNamed: @"123pig0048.png"],

                              nil];

    [123pig setAnimationRepeatCount:1];
    123pig.animationDuration =2.7;
    [123pig startAnimating];


      }
    - (void)tick1{
        [self animatePig1];
    }

    - (void) animatePig1{

        UIImage *pigImage11=[UIImage imageNamed:@"123pig0048.png"];


        if(123pig.image == pigImage11)
            123pig.image = pigImage11;
        else
            123pig.image = pigImage11;






    }
    - (void)stopTimer
    {
    [animationTimer invalidate];
    [animationTimer release];
    [animationTimer1 invalidate];
    [animationTimer1 release];
    }







    -(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [[event allTouches] anyObject];
    CGPoint location = [touch locationInView:touch.view];
    123pig.center = location; 
    }

    - (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    }



    - (void)dealloc {
    [super dealloc];
    [123pig release];
    }
@end

I have an idea that it’s imageNamed thats causing it and that 2.2.1 doesn’t clear it’s cache even after a memory warning, and on another SO question someone said “My understanding is that the +imageNamed: cache should respect memory warnings on iPhone OS 3.0. Test it when you get a chance and report bugs if you find that this is not the case.” Now even if i did download the firmware and SDK of 3.0 I wouldn’t know if it was clearing the cache of imageNamed because I wouldn’t be able to test it on a device! BTW when answering keep in mind that I am new to The iPhone sdk. Thanks in advance.

—————-Edit—————-
I’ve just been accepted into the apple iphone developer program. WOOOHOOO, I’ll check if 3.0 releases cached images properly.

————-Edit——————
Yes it does release cached images. Check my answer below for further clarification.

  • 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-11T23:43:33+00:00Added an answer on May 11, 2026 at 11:43 pm

    Okay people, It would seem that iPhone OS 3.0 does clear cached images on a did receive memory warning command, wooohooo! Me 1, Xcode 0. A bit more detail: In the iPhone os 2.2.1 when you release an animated Image view, the cached images aren’t released, so if your app had loads of animations then eventually the iPhone would run out of memory and quit. So you would just have to go into other more complex methods of animation, and no one wants to do that if they can avoid it. But now releasing does clear the cache! I can tell because when I press a button in my app to animate a view there’s a bit of a wait until the animation plays, then if that is pressed again there is no wait (because it cached it) But then if you press another button that animates that view, the previous cached animation is released! So pressing the first button gives you that original wait, so I can relax now and get on with developing rather then trying to fix a memory management issue that boils down to be apples fault.

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

Sidebar

Ask A Question

Stats

  • Questions 196k
  • Answers 196k
  • 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 You can do some grouping in Linq like this: var… May 12, 2026 at 7:12 pm
  • Editorial Team
    Editorial Team added an answer There are a number of measurements that you could use… May 12, 2026 at 7:12 pm
  • Editorial Team
    Editorial Team added an answer You've already checked that the file does indeed exists, so… May 12, 2026 at 7:12 pm

Related Questions

I am making an application for the iPhone, in which I am creating UITableView
I am running creating an iPhone application which performs a costly operation and I
I'm writing an iPhone app that is mainly centered around grid patterns, so I
I'm attempting to do an ad-hoc distribution of my (first) iPhone App to a

Trending Tags

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

Top Members

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.