summaryrefslogtreecommitdiffstats
path: root/base/message_pump_mac.mm
diff options
context:
space:
mode:
authorthomasvl@chromium.org <thomasvl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-03 01:27:57 +0000
committerthomasvl@chromium.org <thomasvl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-03 01:27:57 +0000
commitf81c6ed15b7e638d874b475aff5b062a444e2d92 (patch)
tree76192f11a9856251ab7e6b5fd219fcd48a1dafcb /base/message_pump_mac.mm
parent17e551be5c3651ac7bcc280d4a01d0610ee702f3 (diff)
downloadchromium_src-f81c6ed15b7e638d874b475aff5b062a444e2d92.zip
chromium_src-f81c6ed15b7e638d874b475aff5b062a444e2d92.tar.gz
chromium_src-f81c6ed15b7e638d874b475aff5b062a444e2d92.tar.bz2
Depending on what runloop we're under, the autoreleasepool might not get cleaned
up until we get a UI event. So we make our CF Source layers use a local pool to make sure we don't collect too much memory before something dumps it. Review URL: http://codereview.chromium.org/20005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9059 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/message_pump_mac.mm')
-rw-r--r--base/message_pump_mac.mm15
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.