メモリ内のヒープショットを見ています。この機能は、放棄されたメモリの原因のようです。
これは、私のビューの1つである「MyView」のビュー構築コードの一部です。
この関数を使用して「MyView」を100回作成および破棄すると、コメント化されたメモリサイズは常にベースラインに戻ります。ただし、この機能をメモリに残しておくと、継続的に増加します。
私が見る限り、私は関数内の何も所有権を持ちません。私は何が間違っているのですか?
-(void)drawPointAroundCircle:(CGPoint)centerpoint radius:(int)radius amount:(int)amount
{
CGPoint pointarray[amount];
float thetaarray[7]={270.0,315.0,0.0,45.0,135,180.0,225.0};
int i=-1;
UIGraphicsBeginImageContext(CGSizeMake(self.frame.size.width,self.frame.size.height));
CGContextRef context=UIGraphicsGetCurrentContext();
for (i=0; i<7; i++) {
float x=cosf(D2R( thetaarray[i]))*radius;
float y =sinf( D2R(thetaarray[i]))*radius;
x=x+centerpoint.x;
y=y+centerpoint.y;
pointarray[i].x=x;
pointarray[i].y=y;
UIBezierPath *path=[UIBezierPath bezierPathWithArcCenter:CGPointMake(x, y) radius:2 startAngle:D2R(0) endAngle:D2R(360) clockwise:YES];
CGContextSetFillColorWithColor(context, [UIColor grayColor].CGColor);
[path fill];
[path closePath];
}
UIImage *bezierimage=UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageView *bezierImageView=[[UIImageView alloc]initWithImage:bezierimage];
[self addSubview:bezierImageView];
}