• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: memory allocation different in simulator and on the iPhone
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: memory allocation different in simulator and on the iPhone


  • Subject: Re: memory allocation different in simulator and on the iPhone
  • From: Dragos Ionel <email@hidden>
  • Date: Fri, 24 Jul 2009 08:04:25 -0400

You are right, I was over releasing and maybe that was crashing the app.
But still, even without [image release] the memory used by the app on iPhone
is slowly increasing (like 3K for each image display). Maybe that is
supposed to happen , maybe something is cached somewhere.

But the good thing is it did not crash anymore after 200-300 images
displayed.

Thanks a lot,
Dragos


On Fri, Jul 24, 2009 at 3:14 AM, Jonathan del Strother <
email@hidden> wrote:

> UIImage* image = [UIImage imageNamed:fileName];
> UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
> [image release];
>
> You're overreleasing the image there.  You sure the phone is dying
> because it's out of memory, rather than because of that?
>
> On Fri, Jul 24, 2009 at 3:07 AM, Dragos Ionel<email@hidden>
> wrote:
> > Hi,
> > I am working on a animal encyclopedia on iPhone. One of the pages
> displays
> > one photo of an animal. When the user swipes the screen the image is
> > replaced with another one.
> >
> > This works fine and when tested in the simulator with the Instrument for
> > Object Allocation, all looks cool.
> >
> > When I tested on the real iPhone with Instrument, the memory used
> increases
> > slowly but constantly so that eventually the application dies.
> >
> > Here is the method that is doing the image changing (direction means if
> the
> > new image should come from left or from right). The class is a
> > UIViewController
> >
> >
> > -(void) displayAnimal: (int) animaIndex fromDirection:(int)direction{
> >
> >  crtIndex = animaIndex;
> >
> >  NSString* animalName = [[animalList objectAtIndex:animaIndex]
> objectForKey:
> > @"name"];
> >
> > NSString* fileName   = [[animalList objectAtIndex:animaIndex]
> objectForKey:
> > @"file"];
> >
> >  self.title = animalName;
> >
> >  //remove all the subviews
> >
> > for (UIView *view in self.view.subviews) {
> >
> > [view removeFromSuperview];
> >
> > }
> >
> >  UIView* backgroundView = [[UIView alloc] initWithFrame:CGRectMake(0, 0,
> 320,
> > 480)];
> >
> > backgroundView.backgroundColor = [UIColor blackColor];
> >
> > [self.view addSubview:backgroundView];
> >
> > [backgroundView release];
> >
> >  UIImage* image = [UIImage imageNamed:fileName];
> >
> > UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
> >
> > [image release];
> >
> >  CGRect imageFrame = imageView.frame;
> >
> > imageFrame.origin = CGPointMake(320*direction,0);
> >
> > imageView.frame = imageFrame;
> >
> >  [self.view addSubview:imageView];
> >
> >
> >  [UIView beginAnimations: nil context: @"identifier"];
> >
> > [UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
> >
> > [UIView setAnimationDuration:0.5];
> >
> >  imageFrame.origin = CGPointMake(0,0);
> >
> > imageView.frame = imageFrame;
> >
> >  [UIView commitAnimations];
> >
> > [imageView release];
> >
> > }
> >
> > Can you see anything that is not right? Why is the memory allocation
> showing
> > different in simulator and on the iPhone?
> >
> > Thanks a lot,
> > Dragos
> > _______________________________________________
> >
> > Cocoa-dev mailing list (email@hidden)
> >
> > Please do not post admin requests or moderator comments to the list.
> > Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> >
> > Help/Unsubscribe/Update your Subscription:
> >
> >
> > This email sent to email@hidden
> >
>
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: memory allocation different in simulator and on the iPhone
      • From: Sven <email@hidden>
    • Re: memory allocation different in simulator and on the iPhone
      • From: Jonathan del Strother <email@hidden>
References: 
 >memory allocation different in simulator and on the iPhone (From: Dragos Ionel <email@hidden>)
 >Re: memory allocation different in simulator and on the iPhone (From: Jonathan del Strother <email@hidden>)

  • Prev by Date: Re: iPhone List? - few questions
  • Next by Date: [OT] Re: iPhone List? - few questions
  • Previous by thread: Re: memory allocation different in simulator and on the iPhone
  • Next by thread: Re: memory allocation different in simulator and on the iPhone
  • Index(es):
    • Date
    • Thread