开发者

I am getting the leak in the following code

开发者 https://www.devze.com 2023-01-17 19:02 出处:网络
I am getting the leaks as 100%. I don\'t know how to release the object after it returns Could you explain the procedure how to release the allocated Titles object.

I am getting the leaks as 100%. I don't know how to release the object after it returns Could you explain the procedure how to release the allocated Titles object.

-(Titles *)listTiles
{
Tiles* tile = [[Tiles alloc] init];
 tile.googleTile_X = (int)tileX;
 tile.googleTile_Y = (int) pow(2, aZoom) - 1- tileY ;
 tile.zoomLevel 开发者_JAVA技巧= aZoom; 
 return tile;
}


You're sending -alloc, and failing to send -release or -autorelease to the object you've created.

Read Apple's introductory documentation on memory management.


In general it depends, but in that particular case I believe you can use return [tile autorelease].

P.S.: Please format your code correctly.


-(Titles *)listTiles
{
    Tiles* tile = [[[Tiles alloc] init] autorelease];
    tile.googleTile_X = (int)tileX;
    tile.googleTile_Y = (int) pow(2, aZoom) - 1- tileY ;
    tile.zoomLevel = aZoom; 
    return tile;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消