summaryrefslogtreecommitdiffstats
path: root/Source/WebKit2/Platform/mac/RunLoopMac.mm
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit2/Platform/mac/RunLoopMac.mm')
-rw-r--r--Source/WebKit2/Platform/mac/RunLoopMac.mm19
1 files changed, 17 insertions, 2 deletions
diff --git a/Source/WebKit2/Platform/mac/RunLoopMac.mm b/Source/WebKit2/Platform/mac/RunLoopMac.mm
index 8258550..828c57f 100644
--- a/Source/WebKit2/Platform/mac/RunLoopMac.mm
+++ b/Source/WebKit2/Platform/mac/RunLoopMac.mm
@@ -30,7 +30,14 @@
void RunLoop::performWork(void* context)
{
- static_cast<RunLoop*>(context)->performWork();
+ // Wrap main thread in an Autorelease pool. Sending messages can call
+ // into objc code and accumulate memory.
+ if (current() == main()) {
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ static_cast<RunLoop*>(context)->performWork();
+ [pool drain];
+ } else
+ static_cast<RunLoop*>(context)->performWork();
}
RunLoop::RunLoop()
@@ -91,7 +98,15 @@ void RunLoop::wakeUp()
void RunLoop::TimerBase::timerFired(CFRunLoopTimerRef, void* context)
{
TimerBase* timer = static_cast<TimerBase*>(context);
- timer->fired();
+
+ // Wrap main thread in an Autorelease pool. The timer can call
+ // into objc code and accumulate memory outside of the main event loop.
+ if (current() == main()) {
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ timer->fired();
+ [pool drain];
+ } else
+ timer->fired();
}
RunLoop::TimerBase::TimerBase(RunLoop* runLoop)