NSWindow 内存选项

NSWindow memory options

在我的项目中使用 NSWindow 时,我通常会指定 realeaseWhenClosed 选项,并在需要时重新加载它。我用谷歌搜索了 NSWindow 内存选项,但找不到任何具体信息:

有人可以向我解释 NSWindow 内存选项的差异,即 deferredone shot缓冲保留非保留.

您应该始终按照此处所述使用缓冲 NSBackingStoreType—Buffered Window Drawing 其他两个选项(保留和非保留)您也不应按照此处所述使用。

Buffered The window renders all drawing into a display buffer and then flushes it to the screen.

You should use this mode. It supports hardware acceleration, Quartz drawing, and takes advantage of the GPU when possible. It also supports alpha channel drawing, opacity controls, using the compositor.

在 OS X v10.0 及更高版本中可用。

The defer argument to initWithContentRect:styleMask:backing:defer: specifies whether the NSWindow creates its window device immediately or only when it's moved on screen. Deferring creation of the window device can offer some performance gain for windows that aren't displayed immediately because it reduces the amount of work that needs to be performed up front. Deferring creation of the window device is particularly useful when creation of the NSWindow itself can't be deferred or when an NSWindow is needed for purposes other than displaying content. Submenus with key equivalents, for example, must exist for the key equivalents to work, but may never actually be displayed.

Memory can also be saved by destroying the window device when the window is removed from the screen. The setOneShot: method controls this behavior. One-shot window devices exist only when their NSWindows are on screen. This means that backing stores are also released when an application is hidden, or when a window is miniaturized.