简体   繁体   English

Xcode 仪器 - 修复泄漏

[英]Xcode instruments - fixing leaks

I have several memory leaks when testing my IOS application in xcode instruments.在 xcode 仪器中测试我的 IOS 应用程序时,我有几个 memory 泄漏。 Can anyone see why the lines marked with "-->" are leaking?谁能看到为什么标有“-->”的行泄漏了?

--> CLLocationCoordinate2D newCoord = CLLocationCoordinate2DMake(latitude, longitude);
--> MapAnnotation* annotation = [[MapAnnotation alloc] initWithCoordinate:newCoord];
[mapView addAnnotation:annotation];
[annotation release];

also, I seem to have some structs which are leaking too;另外,我似乎也有一些结构在泄漏;

--> double placeLat = [place.latitude doubleValue];

there is no pointer to the "placeLat" variable, so I can't release it?没有指向“placeLat”变量的指针,所以我不能释放它? : / :/

thanks谢谢

Christy克里斯蒂

Your code is correct, as much as you show of it.您的代码是正确的,正如您所展示的那样。

One thing you have to keep in mind is that Leaks will show you the place where the leaked object is created, not the place where you do something wrong that will produce the leak.您必须记住的一件事是,Leaks 会向您显示创建泄漏的 object 的位置,而不是您做错会导致泄漏的位置。

This is an important difference.这是一个重要的区别。 Indeed, it could well be, in the first case, that is the very annotation object which is leaked somewhere else in your code.实际上,在第一种情况下,很可能就是annotation object,它在代码的其他地方泄露。 You should check all the flow of execution that Instruments is showing you as stack trace.您应该检查 Instruments 显示为堆栈跟踪的所有执行流程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM