Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.

Commit daa12a8

Browse files
garrettmoonAdlai Holler
authored andcommitted
Need an autorelease pool (#2890)
1 parent 7c4ee35 commit daa12a8

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

AsyncDisplayKit/ASRunLoopQueue.mm

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,21 @@ - (void)threadMain
6060
// 100ms timer. No resources are wasted in between, as the thread sleeps, and each check is fast.
6161
// This time is fast enough for most use cases without excessive churn.
6262
CFRunLoopTimerRef timer = CFRunLoopTimerCreateWithHandler(NULL, -1, 0.1, 0, 0, ^(CFRunLoopTimerRef timer) {
63+
@autoreleasepool {
6364
#if ASRunLoopQueueLoggingEnabled
64-
NSLog(@"ASDeallocQueue Processing: %d objects destroyed", weakSelf->_queue.size());
65+
NSLog(@"ASDeallocQueue Processing: %d objects destroyed", weakSelf->_queue.size());
6566
#endif
66-
weakSelf->_queueLock.lock();
67-
std::deque<id> currentQueue = weakSelf->_queue;
68-
if (currentQueue.size() == 0) {
67+
weakSelf->_queueLock.lock();
68+
std::deque<id> currentQueue = weakSelf->_queue;
69+
if (currentQueue.size() == 0) {
70+
weakSelf->_queueLock.unlock();
71+
return;
72+
}
73+
// Sometimes we release 10,000 objects at a time. Don't hold the lock while releasing.
74+
weakSelf->_queue = std::deque<id>();
6975
weakSelf->_queueLock.unlock();
70-
return;
76+
currentQueue.clear();
7177
}
72-
// Sometimes we release 10,000 objects at a time. Don't hold the lock while releasing.
73-
weakSelf->_queue = std::deque<id>();
74-
weakSelf->_queueLock.unlock();
75-
currentQueue.clear();
7678
});
7779

7880
CFRunLoopRef runloop = CFRunLoopGetCurrent();

0 commit comments

Comments
 (0)