From 4b34be445d4e166ef6524c86f6f9ae9dc3392e03 Mon Sep 17 00:00:00 2001 From: Ruslan Lesiutin Date: Fri, 22 Aug 2025 05:07:02 -0700 Subject: [PATCH] Release PerfMetricsBinding to avoid memory leak (#53420) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/53420 # Changelog: [Internal] HostRuntimeBinding owns a connection, which is stored as a session on HostTarget, so we need to release it first in order to satifsy the assertion in the destructor. Reviewed By: huntie Differential Revision: D80778273 fbshipit-source-id: be7bf085fadd8808fd5e5c621c3990a5e7e0186d --- .../ReactCommon/jsinspector-modern/HostTarget.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/react-native/ReactCommon/jsinspector-modern/HostTarget.cpp b/packages/react-native/ReactCommon/jsinspector-modern/HostTarget.cpp index 80eb2cdd5bd..12af8080e91 100644 --- a/packages/react-native/ReactCommon/jsinspector-modern/HostTarget.cpp +++ b/packages/react-native/ReactCommon/jsinspector-modern/HostTarget.cpp @@ -220,6 +220,11 @@ HostTarget::~HostTarget() { // HostCommandSender owns a session, so we must release it for the assertion // below to be valid. commandSender_.reset(); + + // HostRuntimeBinding owns a connection, so we must release it for the + // assertion + perfMetricsBinding_.reset(); + // Sessions are owned by InspectorPackagerConnection, not by HostTarget, but // they hold a HostTarget& that we must guarantee is valid. assert(