I have a problem concerning memory warnings on the iPhone. I remove 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 app crashes.
What could I do, the subview of my overlay is the problem...
The triangle will be created with "drawRect".
I tested it, without the triangle it would be no problem and the app runs stable.
But only when I add the triangle to the circleView.
When the triangle class is empty, there is the same problem.
- (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;
}