简体   繁体   English

方便构造函数会增加应用程序的大小......?

[英]Do convenience constructor increase the size of the app…?

I am pretty much sure they do... but just wanted to confirm... for instance look at the following code.. 我非常肯定他们会...但只是想确认...例如看下面的代码..

- (void)reset {
NSNumber *zero = [NSNumber numberWithInteger:0];
[self setCount:zero];
}

now this returns an autoreleased object which gets added to the autorelease pool of the app and thus increasing its size... 现在这将返回一个自动释放的对象,该对象将被添加到应用程序的自动释放池中,从而增加其大小...

and this will not be freed unless the app is terminated..? 除非应用程序被终止,否则不会被释放..? Any help is appreciated 任何帮助表示赞赏

The memory is freed the next pass through the application's main event loop. 在下一次通过应用程序的主事件循环时释放内存。

The exact time depends on when your application finishes executing your code and returns to the event loop. 确切的时间取决于应用程序何时完成代码并返回事件循环。 It's during the event loop that, among the tasks that are scheduled, is emptying (draining) the application's autorelease pool. 在事件循环期间,在计划的任务中,正在清空(耗尽)应用程序的自动释放池。

If you're concerned about autorelease pools gaining in size, you could employ your own autorelease pools strategically. 如果您担心自动释放池的大小增加,您可以策略性地使用自己的自动释放池。

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

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