From b8d6ef372663fe6d467144abfc5d2c9352dc28d6 Mon Sep 17 00:00:00 2001 From: SachinTotale Date: Tue, 20 Aug 2019 17:11:50 -0700 Subject: [PATCH] Memory Leak due to JSStringRelease not called in multiple places in JSCRuntime.cpp (#25884) Summary: Memory Leak due to JSStringRelease not called in multiple places in JSCRuntime.cpp Issue: https://github.com/facebook/react-native/issues/25664 Reproducible repo: https://github.com/bhandarijiwan/memory_issue_repro ## Changelog [JSC] [JSCRuntime.cpp] - Added missing JSStringRelease calls in missing places Pull Request resolved: https://github.com/facebook/react-native/pull/25884 Test Plan: Tested that is no memory leak with various NativeModule to JS call flows Reviewed By: JoshuaGross Differential Revision: D16928985 Pulled By: TheSavior fbshipit-source-id: 65ce15ae32482d0db39bad7e22a2fed9ee04f230 --- ReactCommon/jsi/JSCRuntime.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ReactCommon/jsi/JSCRuntime.cpp b/ReactCommon/jsi/JSCRuntime.cpp index a0457397bf22af..00c3a65dfdd5c7 100644 --- a/ReactCommon/jsi/JSCRuntime.cpp +++ b/ReactCommon/jsi/JSCRuntime.cpp @@ -630,7 +630,9 @@ jsi::String JSCRuntime::createStringFromUtf8( size_t length) { std::string tmp(reinterpret_cast(str), length); JSStringRef stringRef = JSStringCreateWithUTF8CString(tmp.c_str()); - return createString(stringRef); + auto result = createString(stringRef); + JSStringRelease(stringRef); + return result; } std::string JSCRuntime::utf8(const jsi::String& str) {