objective c - Few questions on iphone memory management and cocos2d -


I'm working on my first app and have some questions on memory management.

The first question:

I am working on an introduction view that looks like this

  #import "Intro_Scene.h" #import "Main_Menu.h" #import "Label.h" @ Implementation Intro_Scene @ synthesis logo, label; - (id) init {self = [super init]; If (self! = Zero) {// Load logo image and set status logo = [Sprite Spit Withfile: @ "Awalogo page"]; Logo.position = CCP (-50, 0); Logo. scale = 1.8f; [Self combine: logo]; // Logo creates 3 actions for the Sprite ID verb .00 [[Move to action; Duration: 0 Position: CCP (160,270)]; ID verb 1 = [duration of the FedEd verb: 3]; ID Action 2 = [Fadeout Actionwidth Period: 3]; // Logos Runs Functions [Logos Run Action: [Sequence Action: Action 0, Action 1, Action 2, Zero]]; // Amendment Scein Method of Change to switch views in the main menu within 6 seconds of learning. [Self Schedule: @Silctter (Transit Space) Interval: 6.0f]; // creates a label and gives it space, alternative view label = [label labelwith string: @ "alternative views" fontname: @ "wordana" font size: 22]; Label.position = CCP (160, 120); [Self-combined: label]; } Healthy return; } // method has introduced its functions after the introduction, after 6 seconds, it changes the scene - (zero) changes.Secine {[remove self: bridge of people: yes]; [Remove self: label cleaning: yes]; Main Menu * Main Menu = [Main Menu Node]; [[Director shared director] Replaced Sassine: Main Menu]; } - (zero) dealloc {[TextureMgr Shared Layer Mix] Deleted Inappropriate Text]; [Label release]; [LOGO RELEASE]; [Super DeLoc]; } @ And  

Do I have released everything properly, and have leaks? I participated in the equipment several times and did not get any leak and found out about 2 MB memory, is it the amount or expected amount?

Question 2:

My main menu is set in this way

  #import "Main menuH" #Import "Sprite." #import "cocos2d.h" @ Implementation Mainman @ Syntysize Background, ControlLayer; - (id) init {self = [super init]; If (self! = Zero) {// Make default background for main menu, including directional pad and highlight box background = [Sprite Spit WithFile: @ "Main Maneu_bg.png"]; Background.position = CCP (160,240); [Self compound: background]; // Later controls the control in the main menu, the control level displays the class and controls the directional pad and selector. ControlLayer * Layer = [[ControlLayer Elok] Init]; Self.controlLayer = Layer; [Release layer]; [Adding Child: ControlLayer]; } Healthy return; } - (Zero) Delok {[Easily Remove Child: Background Cleanup: Yes]; [[TexturMG shared shared mix] deleted texture used]; [Background release]; [Control release]; [Super DeLoc]; } @end  

Once again am I doing everything correctly? The layer controller I'm adding to this scene is the directional pad sprite that the user uses to navigate menus. In the instrument also it confirms that there is no memory leak, and it uses 4.79 MB of memory. Once again this is a reasonable amount? I would most likely change the possibility to use the Atlasprit and Atlasstrost manager to save the message.

I am new in Cocos 2D, so if you see that I am saying anything wrong! I wanted to fix bad habits in the early stages and if you have any tips in the future for memory management please share.

Do not issue logos, labels or backgrounds You could not copy / copy / keep them new, So you do not keep them yourself and do not release them.

I think the controllers have properties to maintain the property of the liar? If not, then you probably mean to do this.

In general, I used to suggest two things to move forward.

  1. Read and understand
  2. Turn on your code. It is available in Xcode 3.2 through Build-> Build and Analysis It will help detect these memory problems.

Also check


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -