I have a problem with memory alerts on iPhone. I delete overlays and insert new ones. This happens every 5 seconds. But after a while, like half a minute, I get a memory warning, and my application crashes.
What can I do, a subview of my overlay is a problem ...
A triangle will be created using "drawRect".
I tested it, without a triangle this is not a problem, and the application works stably.
But only when I add a triangle to the circle.
When the triangle class is empty, the same problem occurs.
- (MKOverlayView *)mapView:(MKMapView *)map viewForOverlay:(id <MKOverlay>)overlay
{
MKOverlayView *overlayReturn = nil;
if ([overlay isKindOfClass:[MKCircle class]] == YES) {
MKCircleView *circleView = [[[MKCircleView alloc] initWithOverlay:overlay]autorelease] ;
circleView.strokeColor = [UIColor redColor];
circleView.lineWidth = 1;
circleView.fillColor = [[UIColor redColor] colorWithAlphaComponent:0.4];
Triangle* triangle = [[Triangle alloc]initWithFrame:CGRectMake(circleView.circle.radius*10-1000, circleView.circle.radius*10-1000, 2000, 2000)];
triangle.backgroundColor = [UIColor clearColor];
[circleView addSubview:triangle];
[triangle release];
return circleView;
}
Simon source
share