iphone - Problem With memory management in my code -


    -(void)touchesmoved:(nsset *)touches withevent:(uievent *)event {         uitouch *touch=[touches anyobject];         currentpoint=[touch locationinview:self.view];         rootlayer   = [calayer layer];         rootlayer.frame = self.view.bounds;         [self.view.layer addsublayer:rootlayer];         starpath = cgpathcreatemutable();         cgpathmovetopoint(starpath, null, currentpoint.x, currentpoint.y + 15.0);         for(int = 1; < 5; ++i)         {         cgfloat x =  15.0 * sinf(i * 4.0 * m_pi / 5.0);         cgfloat y =  15.0 * cosf(i * 4.0 * m_pi / 5.0);         cgpathaddlinetopoint(starpath, null, currentpoint.x + x, currentpoint.y + y);         }         cgpathclosesubpath(starpath);         shapelayer = [cashapelayer layer];         shapelayer.path = starpath;         uicolor *fillcolor = [uicolor colorwithwhite:0.9 alpha:1.0];         shapelayer.fillcolor = fillcolor.cgcolor;          [rootlayer addsublayer:shapelayer];     }       - (void)dealloc {         [imageview release];         cgpathrelease(starpath);         [super dealloc];     } 

when running performance tool leaks occupying more memory

when iam moving ....

what do....

i need draw star shape on touches movies on layer can perform animations later ....

you're releasing path in dealloc, creating (potentially) many times inside touchesmoved:. can safely release resource @ end of touchesmoved:, please consider doing that.

also, after you've made change, can remove release dealloc, since never have release there longer. path doesn't exist outside method.


Comments

Popular posts from this blog

c++ - Compiling static TagLib 1.6.3 libraries for Windows -

PostgreSQL 9.x - pg_read_binary_file & inserting files into bytea -

Json.NET (Newtonsoft.Json) - Two 'properties' with same name? -