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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:41:48+00:00 2026-05-27T06:41:48+00:00

I will like to know how to release the memory from the animating array,

  • 0

I will like to know how to release the memory from the animating array, somehow in instruments the animating picture are eating up 24MB of real memory. what should i do to release the memory ? the total picture file size are about 3MB in Mac OS.

*EDIT:*Cool, i enabled the ARC setting in the build setting, no longer crashing…but memory usages still hovering around 80 – 120mb physical memory…..

this is the line that run for the image.

    -(void)defaultSetup
{

    self.imageArray = [[NSMutableArray alloc] initWithObjects:
                       [UIImage imageWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"default/d7.jpg"]],
                        [UIImage imageWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"default/d9.jpg"]],
                        [UIImage imageWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"default/d11.jpg"]],
                        [UIImage imageWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"default/d27.jpg"]],
                        [UIImage imageWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"default/d6.jpg"]],                        
                        nil];
    self.defaultID = [[NSMutableArray alloc] initWithObjects:@"0",@"1",@"2",@"3",@"0",nil];
    self.defaultImageCaption = [[NSMutableArray alloc] initWithObjects:@"Ver",@"Green",@"Red",@"Cru",@"East",nil];      


    NSUInteger count = [self.defaultID count];
    NSLog(@"Count %i",[self.defaultID count]);
    NSMutableArray *randomImgName = self.imageArray;
    NSMutableArray *randomID = self.defaultID;
    NSMutableArray *randomName = self.defaultImageCaption;

    for (NSUInteger i = 0; i < count; ++i) {
        // Select a random element between i and end of array to swap with.
        int nElements = count - i;
        int n = (arc4random() % nElements) + i;
        [randomName exchangeObjectAtIndex:i withObjectAtIndex:n];
        [randomImgName exchangeObjectAtIndex:i withObjectAtIndex:n];
        [randomID exchangeObjectAtIndex:i withObjectAtIndex:n];
    }
    self.imageArray = randomImgName;
    self.defaultID=randomID;
    self.defaultImageCaption=randomName;

    NSLog(@"default filename %@",self.defaultImageCaption);
    NSLog(@"default ID %@",self.defaultID);
    self.imageViewTop.alpha = 1.0;
    self.imageViewBottom.alpha = 0.0;
    self.imageViewBottom = [[[UIImageView alloc] initWithFrame:CGRectMake(0,44,320,367)] autorelease];
    self.imageViewTop = [[[UIImageView alloc] initWithFrame:CGRectMake(0,44,320,367)] autorelease];
    [self.view addSubview:imageViewTop];
    [self.view addSubview:imageViewBottom];

    self.buttonCaption = [UIButton buttonWithType:UIButtonTypeCustom];
    //default placement
    self.buttonCaption.frame = CGRectMake(245, 365, 70, 30);
    //[buttonCaption setTitle:@"\u00A9"  forState:UIControlStateNormal];
    [self.buttonCaption addTarget:self action:@selector(buttonCheck) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.buttonCaption];

    [self nextAnimation:buttonCaption.frame.size.width]; 

}

-(void)nextAnimation:(float)previousWidth {

    //picture loop
    imageViewTop.image = imageViewBottom.image;
    imageViewBottom.image = [imageArray objectAtIndex:[imageArray count] - 1];

    [imageArray insertObject:imageViewBottom.image atIndex:0];
    [imageArray removeLastObject];
    imageViewTop.alpha = 1.0;
    imageViewBottom.alpha = 0.0;

    //Name Caption
    NSString * tempCaption = [defaultImageCaption objectAtIndex:[defaultImageCaption count]-1];
    self.dID = [defaultID objectAtIndex:[defaultID count]-1];

    // make the buttons content appear in the top-left
    [buttonCaption setContentHorizontalAlignment:UIControlContentHorizontalAlignmentCenter];
    [buttonCaption setContentVerticalAlignment: UIControlContentVerticalAlignmentCenter ];



    [defaultImageCaption insertObject:tempCaption atIndex:0];
    [defaultImageCaption removeLastObject];
    [defaultID insertObject:dID atIndex:0];
    [defaultID removeLastObject];

    [UIView animateWithDuration:1 delay:2 options:0       
                     animations:^{                          
                         [buttonCaption setTitle:tempCaption  forState:UIControlStateNormal];
                         //NSLog(@"Name %@",tempCaption );
                         //NSLog(@"ID %@",dID);
                     } 
                     completion:^(BOOL  completed)
     {
     }];  
  • 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-27T06:41:48+00:00Added an answer on May 27, 2026 at 6:41 am

    Read up on Cocoa memory management. (I’m assuming you’re not using ARC (automatic reference counting).) Btw, I’d consider using ARC, it makes your life easier. (It’s a compile-time technology, so is backwards compatible with older iOS runtimes, but you don’t get weak reference support on older iOS runtimes.)

    To summarise the memory management rules: everything that increases your retain count on an object should be balanced by something that decreases the retain count at some point.

    Things that increment the retain count:

    self.propertyName = anInstance, when that property is declared with retain property.

    [objectInstance retain].

    [Class alloc], [Class new], [objectInstance copy] or variants beginning with copy.

    Adding an object to a standard collection class (e.g. NSArray).

    Things that decrement the retain count:

    self.propertyName = <some other object instance or nil>, when that property is declared with retain property.

    [objectInstance release]

    [objectInstance autorelease] (causes a release at some later time).

    Removing an object from a standard collection class (e.g. NSArray).

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

Sidebar

Related Questions

I will like to know: I have a scenario. If a user adds a
I would like to know how will performance go when I instantiate multiple classes
I would like to know the procedure which will give the out put about
I would like to know, wether Server.Transfer will work in a Web Farm. Thanking
I know downcasting like this won't work. I need a method that WILL work.
I know there are functions to like is_single() that will return data about the
i will like to know how to set the ar view into landscape mode.
I would like to know how to correctly release a cell and fix a
i will like to seek advise on what should i do next in order
I'd like to measure memory allocation data from my java application, i.e. the sum

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.