• 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 leak when re-alloc Methods
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Memory leak when re-alloc Methods


  • Subject: Re: Memory leak when re-alloc Methods
  • From: Mario Gajardo Tassara <email@hidden>
  • Date: Tue, 15 Apr 2008 20:17:37 -0400


El 15-04-2008, a las 14:21, email@hidden escribió:
I have a nasty leak problem when i realloc several methods of the main class of my app.

Without seeing your code, all I can suggest is making sure you've followed these rules:

http://devworld.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Tasks/MemoryManagementRules.html#

--
I.S.

Problem solved !!! ,

I just moved the alloc and init of  "blisterModelClass_" from:

//the button to star the game and initialize several related methods

- (IBAction)button {

/* blisterModelClass_=[[BlisterModel alloc]init]; */ // here was the leak problem

[blisterModelClass_ cleanMiscArrays];
[blisterModelClass_ initArrays];
[blisterModelClass_ initObjectsArrays];
[blisterModelClass_ initSpriteArrays];
[blisterModelClass_ setObjectsMainData];
[blisterModelClass_ initSpritesObjectsPosition:the_cg_rect_];
[blisterModelClass_ changeCursor];

[NSTimer scheduledTimerWithTimeInterval:0.04
target:self
selector:@selector(refreshDisplay)
userInfo:nil
repeats:YES];


		blisterModelClass_ changeCursor];
	}
}

to the NSView initWithFrameMethod:

-(id)initWithFrame:(NSRect)frameRect {

	self=[super initWithFrame:frameRect];

	if (self) {
		blisterModelClass_=[[BlisterModel alloc]init]; //
		is_full_screen_=FALSE;
		is_anim_started_=FALSE;
	}
	return self;
}

this prevent the re allocation of the same Class instance every time i hit the button to renew the state of the game.

Mario Gajardo Tassara
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 leak when re-alloc Methods
      • From: "Jonathan del Strother" <email@hidden>
    • Re: Memory leak when re-alloc Methods
      • From: Mike Manzano <email@hidden>
  • Prev by Date: Re: "hooking" into another app
  • Next by Date: Re: Core Data for managing subtree?
  • Previous by thread: Re: Memory leak when re-alloc Methods
  • Next by thread: Re: Memory leak when re-alloc Methods
  • Index(es):
    • Date
    • Thread