问题描述
不知道为什么,但是做一个简单的 [[NSOpenPanel openPanel] runModal];
创建一个内存泄漏 - 见Leaks Instrument。
似乎已关闭。
这是一个自动发布的对象,应该不会在ARpool消耗后自动释放?
有没有办法解决这个问题?
NSOpenPanel
这意味着你每次使用它时总是获得相同的对象实例。这意味着第一次调用 [NSOpenPanel openPanel]
时,会创建一个 NSOpenPanel
的实例,并且不会被释放。 / p>
这不是一个泄漏,它是一个优化。但是,有时Leaks仪器会选择这样一次性的实例化作为泄漏,因为实例(从设计上)从未被释放。
NSOpenPanel
是一个广泛使用和测试的类,其标准实现中的任何泄漏都不太可能存在。
Not sure why, but making a simple [[NSOpenPanel openPanel] runModal];
creates a memory leak - seen in Leaks Instrument.
Seems off.
It's an auto-released object, shouldn't it be automatically released after ARpool is drained?
Is there a way to fix this?
NSOpenPanel
is a singleton, which means you always get the same instance of the object every time you use it. This means that the first time you call [NSOpenPanel openPanel]
, an instance of NSOpenPanel
is created and not released.
This is not a leak, it's an optimisation. However, sometimes the Leaks instrument picks up such once-only instantiations as leaks because the instances are (by design) never released.
NSOpenPanel
is such a widely-used and tested class that any leaks in its standard implementation are unlikely to exist.
这篇关于为什么NSOpenPanel / NSSavePanel显示内存泄漏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!