Skip to content

Commit 6022500

Browse files
authored
[Matter.framework] Wrap the MatterControllerFactory shutdown code that is runned with atexit into its own autorelease pool (project-chip#35878)
1 parent cbacbe3 commit 6022500

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/darwin/Framework/CHIP/MTRDeviceControllerFactory.mm

+6-2
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,12 @@
7373
static bool sExitHandlerRegistered = false;
7474
static void ShutdownOnExit()
7575
{
76-
MTR_LOG("ShutdownOnExit invoked on exit");
77-
[[MTRDeviceControllerFactory sharedInstance] stopControllerFactory];
76+
// Depending on the structure of the software, this code might execute *after* the main autorelease pool has exited.
77+
// Therefore, it needs to be enclosed in its own autorelease pool.
78+
@autoreleasepool {
79+
MTR_LOG("ShutdownOnExit invoked on exit");
80+
[[MTRDeviceControllerFactory sharedInstance] stopControllerFactory];
81+
}
7882
}
7983

8084
@interface MTRDeviceControllerFactoryParams ()

0 commit comments

Comments
 (0)