Skip to content

Commit e999da1

Browse files
authored
Autorelease pool growth fix (#255)
* Place each run loop in its own autorelease pool to keep the memory footprint down * fix bracket off typo
1 parent a31bb2d commit e999da1

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

React/CxxBridge/RCTMessageThread.mm

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,13 @@
3636

3737
// This is analogous to dispatch_async
3838
void RCTMessageThread::runAsync(std::function<void()> func) {
39-
CFRunLoopPerformBlock(m_cfRunLoop, kCFRunLoopCommonModes, ^{ func(); });
39+
// Cherry picked from https://github.com/facebook/react-native/pull/27395/files to fix autorelease pool memory growth
40+
CFRunLoopPerformBlock(m_cfRunLoop, kCFRunLoopCommonModes, ^{
41+
// Create an autorelease pool each run loop to prevent memory footprint from growing too large, which can lead to performance problems.
42+
@autoreleasepool {
43+
func();
44+
}
45+
});
4046
CFRunLoopWakeUp(m_cfRunLoop);
4147
}
4248

0 commit comments

Comments
 (0)