pub struct AutoreleasePool { /* private fields */ }Expand description
An autorelease pool, drained when it goes out of scope.
Objective-C’s convention is that a method returning an object it does not own hands back an autoreleased one — alive until the enclosing pool drains. Cocoa’s own event loop provides that pool; a Rust program has none, so without this every temporary AppKit or UIKit object accumulates for the life of the process. It is not a slow leak: capturing a few hundred frames costs tens of megabytes.
Every entry point here that talks to AppKit or UIKit holds one for the duration of the call. Code that loops over such calls wants its own around the loop as well, so peak memory tracks one iteration rather than all of them.
ⓘ
for frame in 0..600 {
let _pool = objc::AutoreleasePool::new();
capture(frame);
}Implementations§
Trait Implementations§
Source§impl Default for AutoreleasePool
impl Default for AutoreleasePool
Source§impl Drop for AutoreleasePool
impl Drop for AutoreleasePool
Auto Trait Implementations§
impl !Send for AutoreleasePool
impl !Sync for AutoreleasePool
impl Freeze for AutoreleasePool
impl RefUnwindSafe for AutoreleasePool
impl Unpin for AutoreleasePool
impl UnsafeUnpin for AutoreleasePool
impl UnwindSafe for AutoreleasePool
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more