Skip to content
Browse files
Add autorelease pool for each run loop for JS Thread (#27395)
Fixes #27327 , we need to create autorelease pool for each run loop in secondary thread, otherwise application may have memory issues. More details can refer to [CreatingThreads](

## Changelog

[iOS] [Fixed] - Add autorelease pool for each run loop for JS Thread
Pull Request resolved: #27395

Test Plan: Example can be found in #27327. No memory spikes any more.

Reviewed By: PeteTheHeat

Differential Revision: D19132504

Pulled By: fkgozali

fbshipit-source-id: d1747f27d36e9a7934966b34aa46d344e06193b3
  • Loading branch information
zhongwuzw authored and facebook-github-bot committed Dec 17, 2019
1 parent eb95b2f commit 948cbfdacc42f8d2640e69f61df55f6adb823fcf
Showing 1 changed file with 6 additions and 1 deletion.
@@ -36,7 +36,12 @@

// This is analogous to dispatch_async
void RCTMessageThread::runAsync(std::function<void()> func) {
CFRunLoopPerformBlock(m_cfRunLoop, kCFRunLoopCommonModes, ^{ func(); });
CFRunLoopPerformBlock(m_cfRunLoop, kCFRunLoopCommonModes, ^{
// Create an autorelease pool each run loop to prevent memory footprint from growing too large, which can lead to performance problems.
@autoreleasepool {

0 comments on commit 948cbfd

Please sign in to comment.