diff options
-rw-r--r-- | base/message_pump_mac.mm | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/base/message_pump_mac.mm b/base/message_pump_mac.mm index 1a8f7b5..1400a78 100644 --- a/base/message_pump_mac.mm +++ b/base/message_pump_mac.mm @@ -139,6 +139,11 @@ void MessagePumpCFRunLoopBase::RunDelayedWorkTimer(CFRunLoopTimerRef timer, void MessagePumpCFRunLoopBase::RunWork(void* info) { MessagePumpCFRunLoop* self = static_cast<MessagePumpCFRunLoop*>(info); + // If we're on the main event loop, the NSApp runloop won't clean up the + // autoreleasepool until there is UI event, so use a local one for any + // autoreleased objects to ensure they go away sooner. + ScopedNSAutoreleasePool autorelease_pool; + // Call DoWork once, and if something was done, arrange to come back here // again as long as the loop is still running. if (self->delegate_->DoWork()) { @@ -151,6 +156,11 @@ void MessagePumpCFRunLoopBase::RunWork(void* info) { void MessagePumpCFRunLoopBase::RunDelayedWork(void* info) { MessagePumpCFRunLoop* self = static_cast<MessagePumpCFRunLoop*>(info); + // If we're on the main event loop, the NSApp runloop won't clean up the + // autoreleasepool until there is UI event, so use a local one for any + // autoreleased objects to ensure they go away sooner. + ScopedNSAutoreleasePool autorelease_pool; + Time next_time; self->delegate_->DoDelayedWork(&next_time); if (!next_time.is_null()) { @@ -174,6 +184,11 @@ void MessagePumpCFRunLoopBase::RunIdleWork(CFRunLoopObserverRef observer, void* info) { MessagePumpCFRunLoop* self = static_cast<MessagePumpCFRunLoop*>(info); + // If we're on the main event loop, the NSApp runloop won't clean up the + // autoreleasepool until there is UI event, so use a local one for any + // autoreleased objects to ensure they go away sooner. + ScopedNSAutoreleasePool autorelease_pool; + if (self->delegate_->DoIdleWork()) { // If idle work was done, don't let the loop go to sleep. More idle work // might be waiting. |