DeFantom
DeFantom

Reputation: 1

Receiving Memory Warning Level =1, Level =2 And Then Crashes

I am Trying To Develop An TilesGame And I Am At The Last Stage. But My Project Begin to Show Unexpected Behaviors. At Random Times It Shows Memory Warning Level =1, Level = 2 and Then, Program received signal: “0”. Data Formatters temporarily unavailable, will re-try after a 'continue'. (Unknown error loading shared library "/Developer/usr/lib/libXcodeDebuggerSupport.dylib") kill quit
I don't know where I am Doing Wrong. I have a Huge number of ImageViews, but they are allocated and released properly.

Is There anything about IBOutlets? I released them in My viewController's Dealloc Method.

In ViewController.h

 @property (nonatomic, retain) MyCustomButton *paveButton;
 @property (nonatomic, retain) MyCustomButton *slackenButton;
 @property (nonatomic, retain) MyCustomButton *tkeeperButton;
 @property (nonatomic, retain) MyCustomButton *spontButton;

 @property (nonatomic, retain) UIImageView *paveHammer;
 @property (nonatomic, retain) UIImageView *slackenHammer;
 @property (nonatomic, retain) UIImageView *tkeeperHammer;
 @property (nonatomic, retain) UIImageView *spontHammer;
 @property (nonatomic, retain) UIImageView *paveKnob;

And In ViewController.m -

 @synthesize paveButton;
 @synthesize slackenButton;
@synthesize tkeeperButton;
@synthesize spontButton;
@synthesize paveHammer;
@synthesize slackenHammer;
@synthesize tkeeperHammer;
@synthesize spontHammer;
@synthesize paveKnob;



- (void)dealloc {
    [super dealloc];
[paveButton release];
[slackenButton release];
[tkeeperButton release];
[spontButton release];
[paveHammer release];
[slackenHammer release];
[tkeeperHammer release];
[spontHammer release];
[paveKnob release];

}

Where am I Doing Wrong? Any Help?
Thanks In Advance.

Upvotes: 0

Views: 1840

Answers (4)

DeFantom
DeFantom

Reputation: 1

Thanks To All Who Have Responded To My Question And Thanks For Ur Advices.I have Fixed My Bug, I really did a silly mistake in my Code Which Caused All That trouble For me.

I have a Huge number of ImageViews, but they are allocated and released properly.

Actually This Was Not right. I had a ImageAnimation And I did it Like This-

- (void) createBorderGlessEffect
{
    borderImage.animationImages = [[NSArray alloc]initWithObjects:
                                    [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"BorderG_1" ofType:@"png"]],
                                    [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"BorderG_2" ofType:@"png"]],
                                    [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"BorderG_3" ofType:@"png"]],
                                    [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"BorderG_4" ofType:@"png"]],
                                    [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"BorderG_5" ofType:@"png"]],
                                    [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"BorderG_6" ofType:@"png"]],
                                    [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"BorderG_7" ofType:@"png"]],
                                    [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"BorderG_8" ofType:@"png"]],
                                    [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"BorderG_9" ofType:@"png"]],
                                    [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"BorderG_10" ofType:@"png"]],
                                    [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"BorderG_11" ofType:@"png"]],
                                    [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"BorderG_12" ofType:@"png"]],
                                    [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"BorderG_13" ofType:@"png"]],
                                    nil];
    [borderImage setAnimationDuration:0.6f];
    [borderImage setAnimationRepeatCount:1];
    [borderImage startAnimating];
}

This Method Is Called repeatedly in My Project, And Look At The Bolded Portion Of My Code, I had Allocated A NsArray Of 13 Objects Which Was Never Been Released.

I am Now doing This-

borderImage.animationImages = [NSArray arrayWithObjects:...

This Answer Is Not Actually related To What I have Questioned, But I Think, I have The responsibility To Mention My Solution here.

Thanks Again.

Upvotes: 0

Warrior
Warrior

Reputation: 39384

The images you have used my be of big size,That's why its causing the error "Memory warning ".Try using the image of very less size and less resolution.

All the Best.

Upvotes: 0

deanWombourne
deanWombourne

Reputation: 38475

It looks like your app is being killed because it's using too much memory (though I guess you already knew that!)

Releasing things in your dealloc method doesn't mean that they will get released if there is low memory.

You need to release any IBOutlets like this :

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc that aren't in use.
    [self setPaveButton:nil];
}

This method gets called when a low memory warning happens.

Only release things in there that can be re-created in a viewDidLoad method in case your view gets re-loaded.

Upvotes: 2

hotpaw2
hotpaw2

Reputation: 70733

The app is trying to use more memory than available. Check for leaks and allocations using Instruments. Maybe try less tiles or smaller tiles.

Upvotes: 0

Related Questions