Reputation: 22042
Dealloc is not called even after release. Here is my code for initialization.
@interface PPTileMap : CCTMXTiledMap
{
}
@end
@implementation PPTileMap
-(void)dealloc
{
printf("Dealloc called\n");
}
@end
//allocation
PPTileMap *tileMap = [[PPTileMap alloc] initWithTMXFile:tilemapFile];
//release
[tileMap release];
tileMap = nil;
When I use tiledMapWithTMXFile then it will..but crashes after loading thread. Why dealloc is not called for above code?
Upvotes: 0
Views: 496
Reputation: 22042
Finally resolved this problem. Special thanks to Morion. Here I explicitly used removeFromParentAndCleanup and then dealloc is called.
//release
[tileMap removeFromParentAndCleanup:YES];
[tileMap release];
tileMap = nil;
Upvotes: 0
Reputation: 10860
The only reason that dealoc
is not called after sending release
that the object is retained by someone else (added to NSArray or NSDictionary, retained by one of your objects, you have run action on it, etc.). If you don't know, what object retains your object, override it's retain
method as
- (id) retain
{
return [super retain];
}
Then place breakpoint inside this method. Then you will be able to see the call stack every time something want to retain your object. You can also override release
method
Upvotes: 3