I have UICollisionBehavior and some boundaries (addBoundaryWithIdentifier:fromPoint:toPoint:): on left, right and bottom side of screen.
I do this (just falling blocks, like a rain):
- (void) movingBlocks {
UIView *block = [[UIView alloc] initWithFrame:
CGRectMake(arc4random() % 320, -20, 20, 20)];
[block setBackgroundColor: [UIColor brownColor]];
[self.view addSubview: block];
[blockCollision addItem: block];
[pushBlock addItem: block];
[self performSelector:@selector(movingBlocks)
withObject:nil
afterDelay:0.5];
}
Then, when collision is happened:
- (void)collisionBehavior:(UICollisionBehavior *)behavior
beganContactForItem:(id<UIDynamicItem>)item
withBoundaryIdentifier:(id<NSCopying>)identifier
atPoint:(CGPoint)p {
if (identifier == (id<NSCopying>)@"bottom") {
[pushBlock removeItem:item];
[blockCollision removeItem:item];
[(UIView*)item removeFromSuperview];
}
}
I remove item from all UIBehaviors and from "superview".
Now my object is invisible, but it still exist in memory.
So, I create two new object every second, but not remove it from memory.
How to dealloc block? How to remove block from memory?
Or maybe i do all wrong and should use another way (e.g. without performSelector:)?
P.S. ARC is enabled.
UPD:
The problem is in UILabel. If delete all UILabels, then memory utilized is not increase and stay on same level. I forgot mention UILabel because thought that it doesn't matter.
Some people have similar problem (this), but i still do not understand what's going on and how to fix that.
You can see my code on github.
Thanks.